Ahmad Kayyali
Ahmad Kayyali

Reputation: 8243

Downloading Hidden file and Viewing it in an UIWebView

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?

Upvotes: 0

Views: 720

Answers (2)

Ahmad Kayyali
Ahmad Kayyali

Reputation: 8243

Found the solution, all I needed to is to change the mode of the file using C Code as follow:

 #include <sys/stat.h> 

 int result = chmod(const char *pathname, mode_t mode);

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

Upvotes: 1

sergio
sergio

Reputation: 69037

I don't know why you are trying to make a file hidden on your web server. If it is so that it will not show in a directory listing, then you could try and use a "." (on all variants of unix, including MacOS X, a file that begins with a period is "hidden"), instead of the hidden file attribute (which is specific to MacOS X), and then try to customize access to hidden files by customizing .htaccess, with the help of this article.

Upvotes: 0

Related Questions