使用asp.net mvc在Dropbox中下载文件 [英] Download a file in Dropbox using asp.net mvc
问题描述
我正在使用asp.net mvc 4
和dropbox-api
从我的保管箱帐户下载文件.我已经在项目中成功安装了api,并且正在关注 本教程 了解功能,但是如果运行我会收到错误消息,
I'm using asp.net mvc 4
and dropbox-api
to download a file from my dropbox account. I've successfully installed the api in my project and I'm following this tutorial to understand the functionalities but I'm getting an error if I run,
指定的参数超出有效值范围. 参数名称:路径
Specified argument was out of the range of valid values. Parameter name: path
这是我的密码,
public async Task<ActionResult> DropDls()
{
var dbx = new DropboxClient("MY-TOKEN");
string folder = "My Folder";
string file = "My File.rar";
using (var response = await dbx.Files.DownloadAsync(folder + "/" + file))
{
await response.GetContentAsStringAsync();
}
return View();
}
我不喜欢api相关的作品,因此无法弄清楚这里有什么问题.但是我需要做到这一点.如果能得到专家的帮助,我将不胜感激.谢谢.
I'm noob to api related works, so can't figure it out what is wrong in here. But I need this to be done. I'll appreciate if I get some help from experts. Thanks.
推荐答案
Dropbox API的非根路径应以"/"开头.您的代码是:
Non-root paths for the Dropbox API should start with "/". Your code is:
string folder = "My Folder";
string file = "My File.rar";
...
using (var response = await dbx.Files.DownloadAsync(folder + "/" + file))
这将导致路径"My Folder/My File.rar",但实际上应为"/My Folder/My File.rar".因此,相反,您可能需要这样的代码:
That will result in a path "My Folder/My File.rar", but it should actually be "/My Folder/My File.rar". So, instead, you probably want code like this instead:
using (var response = await dbx.Files.DownloadAsync("/" + folder + "/" + file))
这篇关于使用asp.net mvc在Dropbox中下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!