重点
post请求,提交的参数数据较大,将参数放入body中,格式为FormData
const formData = new FormData();
prns.forEach(i => {
formData.append('prns', i);
})
let request = new HttpRequest("POST", this.url, formData, {
headers: this.jwt(),
responseType: "blob",
reportProgress: true
})
文件上传
isUploading: Boolean = false;
customReq = (item: UploadXHRArgs) => {
const formData = new FormData();
if (this.fileList.length == 0) {
this.message.error('请上传tif文件!');
return;
}
formData.append('files', this.fileList[0]);
const req = new HttpRequest('POST', this.url, formData, {
});
this.isUploading = true;
return this.http.request(req).pipe(filter(e => e instanceof HttpResponse)).subscribe((raster: HttpResponse<any>) => {
this.isUploading = false;
if (raster.status == 201) {
this.message.success('文件上传成功!');
this.fileList = [];
this.filesDisabled = this.fileList.length == 1;
} else {
this.message.error('文件上传失败!');
}
}, () => {
this.message.error('文件上传失败!');
this.isUploading = false;
})
};
文件下载
<button nz-button nzType="primary" (click)="partDownload()">批量下载</button>
<nz-spin [nzSpinning]="isSearch || isDownload" [nzIndicator]="indicatorTemplate">
<yz-ngx-grid #grid [settings]="settings" [source]="source" (onBaGridReady)="onBaGridReady($event)">
</yz-ngx-grid>
</nz-spin>
<ng-template #indicatorTemplate>
<div style="width: 100%;height:100%;background-color: rgba(255,255,255,0.6);"<