ami*_*mit 6 angular angular-httpclient
我想发送一个带有来自文件的二进制数据的 http POST 请求。当我通过 postman->Body->Binary->Choose file 执行此操作时,我得到了成功的服务器响应。看图片:
但我不知道如何通过 Angular HttpClient 做到这一点。我怎样才能完成以下工作:
set processImage(event) {
console.log(event);
let files: FileList = event.target.files;
let file = files[0];
//send the file as a binary via httpClient
....
Run Code Online (Sandbox Code Playgroud)
ami*_*mit 14
终于让它工作了。以下是任何有需要的人将来参考的代码:
processImage(event) {
console.log(event);
let files: FileList = event.target.files;
let file : File = files[0];
this.http.post(URL, file).subscribe(
(r)=>{console.log('got r', r)}
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7236 次 |
| 最近记录: |