C# 从dropbox获取文件并保存到服务器时出现问题

C# 从dropbox获取文件并保存到服务器时出现问题,c#,dropbox-api,C#,Dropbox Api,这是我从dropbox中选择文件的java脚本代码,当我尝试使用C#将此文件保存到服务器时,我可以看到服务器上的文件,但它是空的。当我尝试打开文件时,文件会出现错误,如“文件已损坏”。使用信号机 options = { // Required. Called when a user selects an item in the Chooser. success: function (files) { alert("Here's the file link: "

这是我从dropbox中选择文件的java脚本代码,当我尝试使用C#将此文件保存到服务器时,我可以看到服务器上的文件,但它是空的。当我尝试打开文件时,文件会出现错误,如“文件已损坏”。使用信号机

options = {

    // Required. Called when a user selects an item in the Chooser.
    success: function (files) {
        alert("Here's the file link: " + files[0].link)
        hub.server.servermethod(files[0].link, files[0].name);
    },

    // Optional. Called when the user closes the dialog without selecting a file
    // and does not include any parameters.
    cancel: function () {

    },

    // Optional. "preview" (default) is a preview link to the document for sharing,
    // "direct" is an expiring link to download the contents of the file. For more
    // information about link types, see Link types below.
    linkType: "preview", // or "direct"

    // Optional. A value of false (default) limits selection to a single file, while
    // true enables multiple file selection.
    multiselect: false, // or true

    // Optional. This is a list of file extensions. If specified, the user will
    // only be able to select files with these extensions. You may also specify
    // file types, such as "video" or "images" in the list. For more information,
    // see File types below. By default, all extensions are allowed.
    extensions: ['.csv', '.xls', '.tsv', '.xlsx', '.txt'],
};
var button = Dropbox.createChooseButton(options);
$('#container').append(button);
function some() {
    Dropbox.choose(options);
}
服务器方法代码为

       // execute the request
           HttpWebResponse response = (HttpWebResponse)
               request.GetResponse();
           // we will read data via the response stream
           Stream resStream = response.GetResponseStream();
           string tempString = null;
           int count = 0;
           Byte[] buffer = new Byte[32 * 1024];
           StringBuilder sb = new StringBuilder();
           do
           {
               // fill the buffer with data
               count = resStream.Read(buffer, 0, buffer.Length);

               // make sure we read some data
               if (count != 0)
               {
                   // translate from bytes to ASCII text
                   tempString = Encoding.ASCII.GetString(buffer, 0, count);

                   // continue building the string
                   sb.Append(tempString);
               }
           }
           while (count > 0); // any more data to read?
           using (FileStream fs = File.Create(System.Configuration.ConfigurationManager.AppSettings.GetValues("DocumentPath").First().ToString() + fileName))
           {
               // Byte[] bufer = new Byte[32 * 1024];
               fs.Write(buffer, 0, buffer.Length);
           }

您正在将
linkType
设置为“预览”,这将为您提供指向文件预览页面的链接,而不是文件内容本身的链接。如果您希望直接访问文件内容,例如,立即以编程方式将内容下载到您的服务器,就像您试图做的那样,您应该使用“direct”
linkType