1

My code for uploading a file to Dropbox is super simple... but it never returns from the call to UploadAsync... the file actually ends up in Dropbox perfectly, but it never returns from the function call... any idea what I might be doing wrong?

using Dropbox.Api;
using Dropbox.Api.Files;
using System;
using System.IO;
using System.Threading.Tasks;

namespace Test
{
    public static class DropboxService
    {    
        private static string DropboxAccessToken = "...";

        public async static Task<bool> UploadFile(Stream stream, string path, string filename)
        {
            using (var client = new DropboxClient(DropboxAccessToken))))
            {
                var updated = await client.Files.UploadAsync(
                    Path.Combine(path, filename),
                    WriteMode.Overwrite.Instance,
                    body: stream);
                // never returns from UploadAsync
            }
            return true;
        }
    }
}
4
  • I plugged this in to a new project and the method returned for me. How big is the data that you're trying to upload? Is there anything about the stream itself or the network connection you're using that would prevent it from completing the upload? Also, how are you checking that UploadAsync isn't returning? You don't seem to be using the return value updated.
    – Greg
    Apr 9, 2019 at 15:16
  • The file is pretty small (a csv with a dozen rows in it)... and the file actually makes it up to Dropbox... I put a breakpoint and stepped over the function call... and it never came back... well at least it wasn't something stupid... but now to figure out what's up... Thanks for double checking me.
    – Brian Rice
    Apr 9, 2019 at 15:22
  • @BrianRice, did you ever figure this out? I'm having the same issue. Jul 29, 2019 at 17:46
  • No I haven't figured out the problem
    – Brian Rice
    Aug 4, 2019 at 15:16

1 Answer 1

0

I don't know exactly why, but it worked for me.

var response = dbx.Files.UploadAsync(folder + "/" + file, WriteMode.Overwrite.Instance, body: stream).Result;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.