Search code examples
iphoneobjective-cuiwebviewfile-accesshidden-files

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?


Solution

  • 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