下载隐藏文件并在 UIWebView 中查看它
我正在将一个文件从服务下载到 txt 类型的 iPhone 中,并在完美运行的 UIWebview
中查看该文件。
但是,当我在下载之前将文件属性设置为隐藏在服务器上时,UIWebview
无法加载该文件,在 webview 委托 webView:didFailLoadWithError:
上,我收到了出现以下错误:
Error Domain=NSURLErrorDomain Code=-1102 "You do not have permission to access the requested resource."
下载文件后可以更改隐藏的文件属性吗?或者还有其他解决方案吗?
I am Downloading a file from service into the iPhone of type txt and I view the file into a UIWebview
that works perfectly.
But when I set the file attribute hidden on the server before I Download it, the UIWebview
can't load the file, on the webview delegate webView:didFailLoadWithError:
I receive the following error:
Error Domain=NSURLErrorDomain Code=-1102 "You do not have permission to access the requested resource."
Can I change the File attribute hidden after I download the file? or there is other solution for this?
找到解决方案,我所需要做的就是使用 C 代码更改文件的模式,如下所示:
if result returns 0 If success -1 > 如果不成功
并根据需要更改模式参数。
参考: chmod() — 更改文件或目录的模式
Found the solution, all I needed to is to change the mode of the file using C Code as follow:
if result returns 0 If successful -1 if unsuccessful
And change the mode argument as you need.
Reference: chmod() — Change the Mode of a File or Directory