apache / cordova-plugin-file-transfer

Apache Cordova File Transfer Plugin
https://cordova.apache.org/
Apache License 2.0
598 stars 885 forks source link

ios is sending cr cf #301

Closed max763 closed 3 years ago

max763 commented 3 years ago

Bug Report

Problem

When sending a file via android to a esp32 device everything is working fine. With iOS the transmitted data has extra cf and lf at the beginning. 0x0d,0x0a, original data starts here...

What is expected to happen?

A correct file upload on iOS.

What does actually happen?

extra two bytes are stuffed at the beginning of the transmitted data. It may also be that the webserver code of the esp32 is handling the http request differently but at least some differences on ios must lead to that behavior.

Information

var options = new FileUploadOptions();
options.fileKey = "file";
options.chunkedMode=false;
options.mimeType="application/octet-stream"; options.httpMethod="POST";

Command or Code

Environment, Platform, Device

The issue was only observed using iOS

Version information

Cordova version 10.0.0 cordova-plugin-file-transfer 1.7.1 "File Transfer"

Checklist

max763 commented 3 years ago

meanwhile I changed CDVFileTransfer.m for ios and it's working now if (mimeType != nil) { //[postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n", mimeType] dataUsingEncoding:NSUTF8StringEnco ding]]; [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", mimeType] dataUsingEncoding:NSUTF8StringEn coding]]; } //[postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Length: %ld\r\n\r\n", (long)[fileData length]] dataUsingEncodin g:NSUTF8StringEncoding]];