Forum Discussion

jimkirk's avatar
jimkirk
Explorer | Level 3
7 years ago
Solved

Cannot upload Image file with Dropbox API in C# - uploading corrupt image instead

Hello. I am trying to upload an image file into my dropbox account with the dropbox api. The image is being uploaded using this code, but it's a corrupt image. Here is my code:   public a...
  • Greg-DB's avatar
    7 years ago

    If you want to upload a local file, you can just do something like this:

    using (var file = new FileStream(srcFile, FileMode.Open))
    {
        var updated = await dbx.Files.UploadAsync(
            targetFolder + "/" + targetFileName,
            WriteMode.Overwrite.Instance,
            body: file);
    }

    You'll probably want to add some checking/exception handling to make sure the local file actually exists at that path though.

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!