Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

Mariam N.1's avatar
Mariam N.1
New member | Level 1
10 years ago

DropboxSDK: error making request to /1/files/sandbox/- (516) (Dropbox V2)

I have a weird error, its weird because my app works perfectly on a simulator but not on the actual iPad. I am speculating here that the issue is with Dropbox requests but please correct me if i am wrong. I am trying to download a file from my folder, so after my log in, i am presented with files in that folder that should be able to download with double tap. Now I get this error : 

[WARNING] DropboxSDK: error making request to /1/files/sandbox/enumrec.pdf - (516) Error Domain=NSCocoaErrorDomain Code=516 "The file couldn’t be saved because a file with the same name already exists." UserInfo={path=/enumrec.pdf, destinationPath=/var/mobile/Containers/Data/Application/29A8C8C7-63F4-4EA0-82AB-846DE72C9859/Documents}

Although this is a brand new file that has never been downloaded! 
Any idea how to resolve this issue?

7 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    [Cross-linking for reference: https://stackoverflow.com/questions/36344171/nscocoaerrordomain-code-516-the-file-couldn-t-be-saved-because-a-file-with-the and https://github.com/dropbox/SwiftyDropbox/issues/69 ]

    Hi Mariam, Chris's comments on the GitHub issue are right. You seem to be supplying only the path to a local folder as the destination to save the file to. You need to supply a full path though, including the local file name you want. 

     

  • Mariam N.1's avatar
    Mariam N.1
    New member | Level 1
    10 years ago

    Thank you for getting back to me Greg, can you please provide an example of what you mean by "full path though, including the local file name you want. " because I thought what i was doing before was providing a full path, and I dont know any other methods to do this frankly. Thanks!

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    To borrow Chris's example, instead of:

    /var/mobile/Containers/Data/Application/29A8C8C7-63F4-4EA0-82AB-846DE72C9859/Documents

    you would need:

    /var/mobile/Containers/Data/Application/29A8C8C7-63F4-4EA0-82AB-846DE72C9859/Documents/enumrec.pdf

    That is, the second one includes the "enumrec.pdf" filename at the end. To get that, you can do something like documentsDirectoryPath.stringByAppendingString(filename)

  • Mariam N.1's avatar
    Mariam N.1
    New member | Level 1
    10 years ago

    but why does this needs to include the file name at the end though? I am just not understanding how this would solve the issue of paths allocation

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    The destination path you supply to the loadFile method tells the SDK where to save the file locally. If there's something already at that path, it will fail, so you should supply a path where there isn't already something saved. Including the file name at the end helps avoid conflicts, e.g., in the case of the error you posted, where you're trying to overwrite "Documents".

  • Mariam N.1's avatar
    Mariam N.1
    New member | Level 1
    10 years ago

    But there wasn't a file with that name before, I uploaded it specifically to check if it would pass but it failed the first time round-where was there a conflict?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    I'm not sure I follow. This question was originally about downloading files, not uploading, correct?

    Can you share some sample code that isn't working as expected?

    If you're asking why /var/mobile/Containers/Data/Application/29A8C8C7-63F4-4EA0-82AB-846DE72C9859/Documents already existed, that seems reasonable, since that's the Documents folder created for you app, unrelated to the Dropbox SDK/file download.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!