我将file
称为File
。如何在file
中传递url
?
importData(repoId: string, file: File ): Observable<any> {
console.log(file);
let url = this.config.getConfig("serviceEndpoints").importRepostory;
url = this.formatString(url, { repoid: repoId, file: file });
console.log(url);
return this.http.post(url, null)
}
答案 0 :(得分:0)
您可以这样做:
const fd = new FormData();
fd.append('file', file);
const req = new HttpRequest('POST', 'TARGET_API_URL', fd, {
reportProgress: true
});
this._http.request(req).pipe(...).subscribe(...); // Inject HTTP client in constructor.