我想将以下cURL命令转换为纯JS:
curl -X POST \
-H "Content-Type: image/jpeg" \
--data-binary '@myPicture.jpg' \
https://parseapi.back4app.com/files/pic.jpg
到目前为止,我能够做到以下几点:
let postUrl = 'https://parseapi.back4app.com/files/'+picUrl;
ParseHeaders.append('Content-Type', 'image/jpeg');
return this.http.post(postUrl, {"name": "anything.jpg"}, {headers: ParseHeaders})
.subscribe(
(body:any) => {
let res = JSON.parse(body._body);
},
error => console.log(error.json())
);
但是,就我认为我需要转换--data-binary
以使其正常工作而言,它对我来说并不起作用!