简体   繁体   English

C#从Dropbox下载文件并将其转换为HttpPostedFile

[英]C# download file from dropbox and convert it to HttpPostedFile

My web site has an option to upload files from local computers. 我的网站可以选择从本地计算机上载文件。 I want to now add an option to upload files straight from dropbox. 我现在想添加一个选项,直接从Dropbox上传文件。 I am using the dropbox chooser api which returns the link for the file chosen by the client. 我正在使用保管箱选择器api,该API返回客户端选择的文件的链接。

I then want to download the file to the server and convert it to HttpPostedFile or post it again as a HttpPostedFile - because my functions expect a HttpPostedFile object... 然后,我想将文件下载到服务器并将其转换为HttpPostedFile或再次将其发布为HttpPostedFile因为我的函数期望使用HttpPostedFile对象...

Can somebody help me find a way to do that? 有人可以帮我找到一种方法吗?

idan. 伊丹

You need to make your own class that inherits HttpPostedFileBase and implements its methods using the Dropbox API. 您需要创建自己的类,该类继承HttpPostedFileBase并使用Dropbox API实现其方法。

You can then pass that class for files from Dropbox, and HttpPostFileWrapper for regular uploads. 然后,您可以将该类传递给Dropbox中的文件,并将HttpPostFileWrapper传递给常规上传。

If you're using ASP.Net MVC, you will get HttpPostedFileBase directly for regular uploads, and you can create a custom model binder to automatically handle Dropbox too. 如果您使用的是ASP.Net MVC,则可以直接获取HttpPostedFileBase进行常规上传,还可以创建自定义模型绑定程序来自动处理Dropbox。

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

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