问题描述
private postDocuments(url: string,category: string,fileImage: File,mimeType: string): Observable<{}> {
const headers : HttpHeaders = new HttpHeaders()
.set('Authorization',`Basic ${btoa(this.PUBLISHABLE_KEY)}`)
.set('Content-Type','multipart/form-data');
const fileBlob : any = new Blob([fileImage],{ type: `image/${mimeType}` });
const fd : FormData = new FormData();
fd.append('file',fileBlob);
fd.append('category',category);
return this.http.post(url,fd,{ headers });
}
收费:
selectFiletoUpload(event:any) : void {
this.fileImage = event.target.files[0];
this.fileName = this.fileImage.name;
}
并接收:
{“error”:{
“status”:“Bad Request”,“status_code”:400,“type”:“nvalid_request_error”,“category”:“missing_required_param”,“message”:“Missing required param: file. Please verify request parameters.”}}
我使用了邮递员,它工作正常,但在我的代码中什么也没做。 我无法访问来自信用卡的 api。 在带有 curl 函数的 PHP 上:curl_file_create 可以运行,但在 Blob 中不可以。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)