【问题标题】:How to upload file with the 10GB+ size in ASP.NET C#如何在 ASP.NET C# 中上传 10GB+ 大小的文件
【发布时间】:2016-07-07 16:30:48
【问题描述】:

我正在尝试上传大小超过 10GB+ 的文件,并且我想在服务器上上传多个文件。

我在Web.config 中进行了一些更改以上传大文件。

 <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime executionTimeout="6000000" maxRequestLength="2147483647"/>
  </system.web>

  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147483647" />
      </requestFiltering>
    </security>
  </system.webServer>

但它只支持最大 2GB 的文件大小。我做了太多的研究,但我找不到任何可以帮助我上传 10GB+ 文件大小的东西。

我看了一些文章说最大文件大小限制是2GB

Maximum value of maxRequestLength?

IIS 7 httpruntime maxRequestLength limit of 2097151

https://blogs.msdn.microsoft.com/prashant_upadhyay/2011/07/12/large-file-upload-issue-in-asp-net/

我发现了一些技巧,我在客户端(浏览器)对文件进行切片并将所有切片上传到服务器,然后将所有切片合并到单个文件中。

但是这样做可能是错误的想法,如果某些文件未能上传或丢失,则文件可能已损坏。

我不想实现Slice and Upload and Merge 文件技术来上传大文件。

还有其他方法可以使用 ASP.NET 和 C# 上传更大的文件(10GB+ 大小)。

谢谢。

【问题讨论】:

  • FTP 是个好主意,但我必须在网站上向客户端提供接口来上传文件,而且该文件不是简单文件。我必须提取文件的内容并根据文件的内容执行额外的任务。谢谢@Pikoh

标签: c# asp.net file-upload upload


【解决方案1】:

只用这个

<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime executionTimeout="6000000" maxRequestLength="10485760"/>
</system.web>

从 web.config 中删除以下代码

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="2147483647" />
  </requestFiltering>
</security>

10gb = 10485760 kb

【讨论】:

  • 这行不通,因为maxRequestLength只有字节,它的类型是int32,所以它不能上传10GB的文件。如果我按照你说的设置它只上传10MB文件
  • 我永远不会删除你说的块代码。因为我正在使用Server:Microsoft-IIS/8.0 并且在Server:Microsoft-IIS/7.0+ 之后需要块代码..
猜你喜欢
  • 2013-07-28
  • 2023-01-11
  • 1970-01-01
  • 2012-09-11
  • 2015-06-14
  • 1970-01-01
  • 2010-09-22
  • 2011-03-13
  • 2014-08-25
相关资源
最近更新 更多