multipartform data - Cordova File Transfer remove Multipart or Content-Disposition Header -


i managed upload image server using cordova file transfer plugin.

var img = <full path image> var url = <url webservice>  var options = new fileuploadoptions(); //no specified options, using defaults var ft = new filetransfer(); ft.upload(img, encodeuri(url), win, fail, options);  var win = function (r) {     console.log('successfully sent'); } var fail = function (error) {     console.log("an error has occurred: code = " + error.code); }; 

however, server had problems reading image due header added plugin.

--+++++..content-disposition: form-data; name="file"; filename="filename.jpg"..content-type: image/jpeg.... 

took me awhile figure way removed multipart header. here's solution/work around.

open: \platforms\android\src\org\apache\cordova\filetransfer\filetransfer.java

look for:

sendstream.write(beforedatabytes); totalbytes += beforedatabytes.length; 

comment away or delete these 2 lines. code adds multipart header.

also remove:

sendstream.write(tailparamsbytes); totalbytes += tailparamsbytes.length; 

this code adds tail multipart header.

i have done md5 checksum check , of same now.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

python - How to remove the Xframe Options header in django? -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -