[英]Uploading large files not working on windows?
我正在尝试使用 Angular 上传大文件(让我们考虑人类基因组 tar 文件,最小 2.5gb)。如果我从 Linux(在任何浏览器、chrome 或 Firefox 中)上传它,它正在工作,但相同的文件上传不适用于 windows (甚至是 chrome 浏览器)。 以下是一个服务文件,
import { HttpHeaders, HttpClient, HttpParams, HttpEventType } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class GenomeService {
baseApiUrl = '###myapiurl###';
public postGenome = (resrc: string, item: any): Observable<any> => {
this.headers = this.headers.delete('Content-Type');
return this._http.post(this.baseApiUrl + resrc + "/", item, {
headers: this.headers,
withCredentials: true,
reportProgress: true,
observe: 'events'
}).pipe(
map((event) => {
switch (event.type) {
case HttpEventType.UploadProgress:
const progress = Math.round(100 * event.loaded / event.total);
return { status: 'progress', message: progress };
case HttpEventType.Response:
return event.body;
default:
return "Error......${event.type}";
}
}),
finalize(() => {
console.log("done");
})
);
}
}
在 browser.network tabit 中显示为net::ERR_CONNECTION_RESET
。 我不知道,我在哪里犯了错误..?
检查(在您的后端设置中)一些名为 maxRequestSize 或 maxRequestLength 的参数。 如果我们知道您使用的是哪种后端,那就更容易了。 如果是 DOT.NET,它会是这样的:
<httpRuntime maxRequestLength="xxx" />
根据您的需要进行设置
如果您使用IIS
托管您的应用程序,则默认上传文件大小为4MB
。 要增加它,请在您的web.config
中使用以下部分。
注意: maxAllowedContentLength
以bytes
为单位,而maxRequestLength
以kilobytes
为单位,这就是此config
示例中值不同的原因:
<system.webServer>
<security>
<requestFiltering>
<!-- For 50 MB set maxAllowedContentLength="52428800" -->
<requestLimits maxAllowedContentLength="52428800" />
</requestFiltering>
</security>
</system.webServer>
<!--For 50 MB set maxRequestLength="51200"-->
<httpRuntime targetFramework="4.5" maxRequestLength="51200" executionTimeout="30" />
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.