简体   繁体   English

Dropnet Web服务下载文件

[英]Dropnet web service download file

I'm developing a web service using WCF. 我正在使用WCF开发Web服务。 This web service use JSON to communicate with the clients. 该Web服务使用JSON与客户端进行通信。 Furthermore it provides several methods using the DropNet API. 此外,它提供了使用DropNet API的几种方法。 Now I need to download a file, so I created a method called DownloadFile(...). 现在我需要下载一个文件,因此创建了一个名为DownloadFile(...)的方法。 What should I do to return the file using JSON? 我应该怎么做才能使用JSON返回文件? The DropNet method: GetFile(string path) returns a byte array, after calling this method how can i return the file to the client?? DropNet方法:GetFile(string path)返回一个字节数组,调用此方法后如何将文件返回给客户端? I hope it's all clear. 我希望一切都清楚。 Thank you 谢谢

At the moment my method return a shared url: 目前,我的方法返回一个共享的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;

    }

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. 但是,我更喜欢直接从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. 获取“共享网址”,并将查询字符串参数dl = 1添加到该URL,这将触发对该URL的直接下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM