unAuthorizedAccessException-more details

0 votes
allo akshay

to your answer about the local access denied for your info in my code it was able to create write and read the new file in the persistentDataPath. but only when using upload from you API that gave the exception. That is what puzzles me. how come my code can create write and read using c# streamWriter and streamReader, but not yours ?

daniel
related to an answer for: unauthorizedAccessException-more details
asked May 23, 2014 in App42 Cloud API-BaaS by mrdaniel (10 points)

1 Answer

0 votes
Hello MrDaniel,

Are you ever tried to upload a file by giving its path, if not then try to upload a simple file by giving its exact path.

If there is no error, then try to upload your I/O streaming created file to upload and if error occurs, means you are trying to upload a file that has not been created yet. So, firstly check your file is successfully created then Upload it.

Thanx.

Akshay.

And you don't need to always open a new thread for your same question, you can comment here, so that we figure out and solve the problem together in same thread, this is more flexible rather than asking same question in another thread.
answered May 24, 2014 by Akshay.Mishra (179 points)
i'd moved the "view1.txt" file to /Users/Daniel and to /Desktop but still got that access is denied problem in both Mavericks and SnowLeopard. how come ? I too have tried in your upload method the path with a backslash and without but no good. i have also deliberately added a user "daniel" with R & W rights  for that Volume but no good. Next i did push to Android device using the standard ApplicationPesistentDataPath and the text file name but check you HQ no file is being uploaded.
2. i run same code in windows xp also got access denied:

UnauthorizedAccessException: Access to the path 'C:/Documents and Settings/daniel.MACBOOK/Local Settings/Application Data/APProducer/u3appFramework14k01a' is denied.
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options)
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share)
(wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
System.IO.File.OpenRead (System.String path)
System.IO.File.ReadAllBytes (System.String path)
com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW.ExecuteMultipart (System.String name, System.String filePath, System.Collections.Generic.Dictionary`2 queryParams, System.Collections.Generic.Dictionary`2 postParams, System.Collections.Generic.Dictionary`2 headerParams, System.String url, System.String accept, App42CallBack callBack)
com.shephertz.app42.paas.sdk.csharp.upload.UploadService.UploadFile (System.String name, System.String filePath, System.String fileType, System.String description, App42CallBack callBack)
AppCloud42SERVICEmanager.Update () (at Assets/script/appMono/AppCloud42/AppCloud42SERVICEmanager.cs:413).

3. i did a couple of upload manually from the appHQ upload page and selected the same text file both attempts were uploaded. So accessing the file via the web had no issue but how come running the code from the unity IDE got access denied and upload code run from the devices not effective.
There is a sample for Upload file..
https://github.com/AkshayMShepHertz/App42-Unity3D-Upload
I hope this will help you a lot.
And one more thing i saw in your exception message, that you are trying to upload the file in the Update method, so try to upload the file on a button click...
the code though its inside the Update cycle but its as good as a button because i have a flag that enables it to call your method only once like this:
if(!bToUploadFile){
   bToUploadFile = true; /// this inhibit next entry so no execution next update.
    uploadService.UploadFile(
          "view1.txt",
              "/Users/Daniel/Desktop/",  /// sAppPersistentDataPath,
          UploadFileType.TXT,
           "upload by code",              /// sDescription,
          new AppCallBack_fileUpload()
    ); ///end of uploadService.UploadFile
App42Log.Console("UploadFile in progress");
  }///end of if(!bToUploadFile)

and the debug log showed up in the editor only once so there is no hundreds of apiHits as per my earlier experience. (if you recall i requested for your end to remove those for-loop calls which was adding up to over 800 per session on a single day).

back to the current issue can you provide a test snippet so i can embed in my code to test the upload ?
O.K, I created a sample for upload file. You can download it from dropBox :- https://www.dropbox.com/s/xng2vbwjiuka64h/App42Upload.zip
And tell me if it helps.
your example is indeed useful as i saw the diff in which you define the 'filePath'. though i'd sent you my snippet it might not be obvious to you the 'filePath' was the issue. my 'filePath' is strictly the path to the file. If you look at your doc page it stated that filePath - the local path for the file. But in your example the 'filePath' is the path to the file and including the file. So it took quite a few days to sort that out. maybe you need to rephrase your doc. BTW why do your api need a filename and a 'filePath' if the 'filePath' already has the filename ?
Thanx for giving us your valuable feedback, we will improve our docs.
And for your question about fileName so, the fileName is works as a uniqui ID for the file as you can call the other methods like GetFileByName, RemoveFileByName etc.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...