简体   繁体   English

上传大文件在 windows 上不起作用?

[英]Uploading large files not working on windows?

I am trying to upload the large file(let's consider Human Genome tar file, minimum 2.5gb) using Angular. If I upload it from Linux(in any browser, chrome or Firefox) it is working, But same file upload not working on windows (even chrome browser).我正在尝试使用 Angular 上传大文件(让我们考虑人类基因组 tar 文件,最小 2.5gb)。如果我从 Linux(在任何浏览器、chrome 或 Firefox 中)上传它,它正在工作,但相同的文件上传不适用于 windows (甚至是 chrome 浏览器)。 Following is a service file,以下是一个服务文件,

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");
            })
        );

    }

}

In the browser.network tabit is showing as net::ERR_CONNECTION_RESET .在 browser.network tabit 中显示为net::ERR_CONNECTION_RESET I don't know, where I am making the mistake..?我不知道,我在哪里犯了错误..?

Check ( on your backend' ssettings ) some parameter called maxRequestSize or maxRequestLength.检查(在您的后端设置中)一些名为 maxRequestSize 或 maxRequestLength 的参数。 It would have been easier if we know what kind of backend you're using.如果我们知道您使用的是哪种后端,那就更容易了。 If it's DOT.NET, it would be something like this:如果是 DOT.NET,它会是这样的:

<httpRuntime maxRequestLength="xxx" />

set it depending to your needs根据您的需要进行设置

If you are using IIS for hosting your application, then the default upload file size if 4MB .如果您使用IIS托管您的应用程序,则默认上传文件大小为4MB To increase it, use this below section in your web.config .要增加它,请在您的web.config中使用以下部分。

Note: maxAllowedContentLength is measured in bytes while maxRequestLength is measured in kilobytes which is why the values differ in this config example:注意: maxAllowedContentLengthbytes为单位,而maxRequestLengthkilobytes为单位,这就是此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" /> 

Hope this helps.希望这可以帮助。

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

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