Cordova File Transfer remove Multipart or Content-Disposition Header

前端 未结 4 753
暖寄归人
暖寄归人 2020-12-21 11:34

I managed to upload an image to my server using Cordova File Transfer plugin.

var img = 
var url = 

var o         


        
4条回答
  •  春和景丽
    2020-12-21 12:02

    Based on the source code:

    boolean multipartFormUpload = (headers == null) || !headers.has("Content-Type");
    if (multipartFormUpload) {
      conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
    }
    

    You can find it is easy to disable the multipart header by setting a dummy header option in your javascript:

    options.headers = {"Content-Type":"dummy"}; // set it to something to avoid the plug-in append the header
    

提交回复
热议问题