我正在从服务执行 http get 请求。
https://angular.io/guide/http-request-data-from-server
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class TestService {
constructor(private http: HttpClient) { }
downloadFile(URL) {
return this.http.get(url);
}
}
如果我使用上述功能下载 500 MB 文件,则需要大约 30 秒。
downloadFile(URL) {
return this.http.get(url, { responseType: 'blob'});
}
进行上述更改后,需要更多时间,大约 40 秒。
以 BLOB 形式获取文件数据并提高性能的最佳方法是什么?
我们可以做些什么来提高 Typescript/Angular 方面的性能?
根据您的文件有多大,首先有多种简单的解决方案可以解决此用户体验问题:
更高级: