简体   繁体   English

使用C#和ASP.NET保存到Dropbox文件夹

[英]Saving to Dropbox folder using C# and ASP.NET

I have an MVC 4 application that generates excel spreadsheets from a template stored on my shared hosting FTP, but I would like the generated files to be stored in the user's dropbox folder, not the server. 我有一个MVC 4应用程序,该应用程序从存储在共享托管FTP上的模板生成excel电子表格,但我希望将生成的文件存储在用户的保管箱文件夹中,而不是服务器中。 How can I accomplish this using C#? 如何使用C#完成此操作?

My files are currently saved as follows: 我的文件当前保存如下:

ExcelPackage p = new ExcelPackage(tempFile);

string newpath = Path.Combine(Server.MapPath("~/Content"), "Invoice.xlsx");
            FileInfo newFile = new FileInfo(newpath);
            p.SaveAs(newFile);

tempFile is the template, which isnt relevant here. tempFile是模板,此处不相关。 This code stores it on the server which I don't want. 此代码将其存储在不需要的服务器上。

You can do this by using the DropBox API . 您可以使用DropBox API进行此操作。

Unfortunately there is no official API for .Net, but you can find some on the Web like: 不幸的是,没有用于.Net的官方API,但是您可以在网上找到一些类似的文件:

I let you check how they work and determine which one is more appropriate to your project, but by looking at the DropBox PHP API it doesn't seem very difficult. 我让您检查它们的工作方式,并确定哪个更适合您的项目,但是通过查看DropBox PHP API似乎并不困难。 It is based on HTTP and OAuth. 它基于HTTP和OAuth。

You will not have any C# code running on the client in a web application and very doubtful you'd get the permission in any web application. 您不会在Web应用程序的客户端上运行任何C#代码,并且非常怀疑您是否会在任何Web应用程序中获得许可。 What you'd might want to consider is offer the user to download the file, suggesting they put it in their dropbox folder. 您可能要考虑的是为用户提供下载文件的建议,建议他们将其放在其保管箱文件夹中。

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

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