Search code examples
c#jsonwcfrestdropnet

Dropnet web service download file


I'm developing a web service using WCF. This web service use JSON to communicate with the clients. Furthermore it provides several methods using the DropNet API. Now I need to download a file, so I created a method called DownloadFile(...). What should I do to return the file using JSON? The DropNet method: GetFile(string path) returns a byte array, after calling this method how can i return the file to the client?? I hope it's all clear. Thank you

At the moment my method return a shared url:

public string DownloadFile(UserCredential data)
    {
        DropNetClient _client = new DropNetClient(data.appKey, data.appSecret);

        _client.UserLogin = new UserLogin() { Token = data.token, Secret = data.secret };

        var file = _client.GetShare(data.root);
        return file.Url;

    }

Solution

  • There are a few things you can do such as save the file to disk then download it etc.

    But I prefer the semi-hack to download directly from Dropbox. Get the Share Url and add a query string parameter dl=1 to the url and that should trigger a direct download on that url.