"No filename found in "Content-Disposition" header。必须提供 "filename=FILENAME" 格式的文件名"
"No filename found in "Content-Disposition" header. A file name in the format "filename=FILENAME" must be provided"
我正在尝试使用 REST 将音频文件从 ionic 4 上传到 drupal 8 站点 API
代码是:
public uploadAudio(audioData,token,auth){
let audio={
uri:"public://"+new Date().getTime()+'.mp3',
file:audioData,
filename:new Date().getTime()+'.mp3'
}
let body=JSON.stringify(audio);
let options ={ headers: new HttpHeaders({ 'Content-Type': 'application/octet-stream','Accept':'application/json','X-CSRF-Token':token ,'Authorization':'Basic '+auth ,'Content-Disposition': "file;filename=\'filename.mp3\'"}) };
console.log(options);
return this.httpClient.post(this.Drupal_URL+'file/upload/node/question/field_userq?_format=json',body,options);
当我 post 这个错误显示
"No filename found in "Content-Disposition" header. A file name in the format "filename=FILENAME" must be provided"
有什么想法吗?
解决办法是把header改成
let options ={ headers: new HttpHeaders({ 'Content-Type': 'application/octet-stream','Accept':'application/json','X-CSRF-Token':token ,'Authorization':'Basic '+auth ,"Content-Disposition": "file; filename=\"$name.mp3\"\r"}) };
我正在尝试使用 REST 将音频文件从 ionic 4 上传到 drupal 8 站点 API 代码是:
public uploadAudio(audioData,token,auth){
let audio={
uri:"public://"+new Date().getTime()+'.mp3',
file:audioData,
filename:new Date().getTime()+'.mp3'
}
let body=JSON.stringify(audio);
let options ={ headers: new HttpHeaders({ 'Content-Type': 'application/octet-stream','Accept':'application/json','X-CSRF-Token':token ,'Authorization':'Basic '+auth ,'Content-Disposition': "file;filename=\'filename.mp3\'"}) };
console.log(options);
return this.httpClient.post(this.Drupal_URL+'file/upload/node/question/field_userq?_format=json',body,options);
当我 post 这个错误显示
"No filename found in "Content-Disposition" header. A file name in the format "filename=FILENAME" must be provided"
有什么想法吗?
解决办法是把header改成
let options ={ headers: new HttpHeaders({ 'Content-Type': 'application/octet-stream','Accept':'application/json','X-CSRF-Token':token ,'Authorization':'Basic '+auth ,"Content-Disposition": "file; filename=\"$name.mp3\"\r"}) };