Ionic3 HttpClientModule multipart/form-data

问题描述

我有这个代码

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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...