react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

RNFS.uploadFiles [Error: unexpected end of stream] framesToPop: 1, code: 'EUNSPECIFIED'

Open cafeasia3 opened this issue 7 years ago • 17 comments

I tried it on android emulator, I am using the sample upload code and it return [Error: unexpected end of stream] framesToPop: 1, code: 'EUNSPECIFIED'

This is the code I am using

async uploadImageReq(){
    var url = this.API_BASE_URL + '/api/addimages/'
    var uploadBegin = (response) => {
      var jobId = response.jobId;
      console.log('UPLOAD HAS BEGUN! JobId: ' + jobId);
    };

    var uploadProgress = (response) => {
      var percentage = Math.floor((response.totalBytesSent/response.totalBytesExpectedToSend) * 100);
      console.log('UPLOAD IS ' + percentage + '% DONE!');
    };
    console.log('check url', url, files) 
    return await RNFS.uploadFiles({
      toUrl: url,
      files: files,
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'Authorization': 'Bearer ' + this._sessionToken,
        'Connection': 'close'
      },
      fields: {
        'hello': 'world',
      },
      begin: uploadBegin,
      progress: uploadProgress
    }).promise.then((response) => {
        console.log('result', response)
        return response
        if (response.statusCode == 200) {
          console.log('FILES UPLOADED!'); // response.statusCode, response.headers, response.body
        } else {
          console.log('SERVER ERROR');
        }
      })
      .catch((err) => {
        if(err.description === "cancelled") {
          // cancelled by user
        }
        console.log('ERROR',err);
      })
  }

Should be same code as sample code on the documentation. it stop at console.log('UPLOAD HAS BEGUN! JobId: ' + jobId);

then error

[Error: unexpected end of stream] framesToPop: 1, code: 'EUNSPECIFIED'

Any idea What cause this error?

cafeasia3 avatar Dec 13 '18 07:12 cafeasia3

Could you use Android studio to get the log so I can inspect it, thank you!

hank121314 avatar Dec 14 '18 01:12 hank121314

Check your file paths. Could you provide the log of this console.log('check url', url, files)?

dhl1402 avatar Dec 16 '18 14:12 dhl1402

@cafeasia3 did you solve your issue?

sebqq avatar Feb 02 '19 13:02 sebqq


java.net.MalformedURLException: no protocol: /calamity/pdf/38
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at java.net.URL.<init>(URL.java:601)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at java.net.URL.<init>(URL.java:498)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at java.net.URL.<init>(URL.java:447)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at com.rnfs.RNFSManager.downloadFile(RNFSManager.java:634)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at android.os.Handler.handleCallback(Handler.java:873)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at android.os.Looper.loop(Looper.java:193)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
2019-02-28 17:03:11.851 7269-10472/com.eyeontarget W/System.err:     at java.lang.Thread.run(Thread.java:764)
2019-02-28 17:03:11.855 7269-10471/com.eyeontarget I/ReactNativeJS: { [Error: no protocol: /calamity/pdf/38]
      framesToPop: 1,
      nativeStackAndroid: [],
      userInfo: null,
      code: 'EUNSPECIFIED' }

RichardLindhout avatar Feb 28 '19 16:02 RichardLindhout

My url was wrong ;)

RichardLindhout avatar Feb 28 '19 16:02 RichardLindhout

sampe problem

aliakbarazizi avatar Apr 16 '19 13:04 aliakbarazizi

@aliazizi Can you provide a log as RichardLindhout have provided? So I can research this bug.

hank121314 avatar Apr 17 '19 05:04 hank121314

I use react-native-document-picker wich provide content:// uri for file, And use it's example to upload file with this library. I figure out the problem is from example code, also this library can't use content:// uri so i changed my code and use fetch api for uploading and everything is working now

aliakbarazizi avatar Apr 21 '19 18:04 aliakbarazizi

@aliazizi hey, can you send example code.

MuhammetAdamoglu avatar May 11 '19 11:05 MuhammetAdamoglu

@samueljmurray Im sorry I make a mistake, It's example of https://github.com/Elyx0/react-native-document-picker in readme, I send wrong post here

aliakbarazizi avatar May 15 '19 17:05 aliakbarazizi

I am also getting the same error. I am not getting the real Path of file.

Someone, please help

sandeepsinghs avatar Jun 03 '19 06:06 sandeepsinghs

I'm getting the same error {"framesToPop": 1, "code": 'EUNSPECIFIED', "message": "unable to resolve host \"api.server.com" No address associated with hostname", "line": 32, "column": 1111 }

I have the following code

RNFS.uploadFiles({
      toUrl: uploadUrl,
      files,
      method: "POST",
      headers: {
        Accept: "application/json",
        // "Transfer-Encoding": "Chunked",
        // "Content-Type": "multipart/form-data",
        "X-Access-Token": accessToken,
      },
      fields: {},
      begin: uploadBegin,
      connectionTimeout: 1500,
      readTimeout: 1500,
      progress: uploadProgress,
    })
      .promise.then(response => {
        if (response.statusCode == 200) {
          console.log("FILES UPLOADED!:"); // response.statusCode, response.headers, response.body
          onSuccess(JSON.parse(response.body));
        } else {
          console.log("SERVER ERROR");
          failureCallback(`Server Error: ${response.body.stringify()}`);
        }
      })
      .catch(err => {
        if (err.description === "cancelled") {
          // cancelled by user
        }
        console.log(`RNBlob.uploadFile error: ${err.messsage}`);
        failureCallback(err);
      });

File-path is "/data/user/0/com.example.app/cache/audioVideoFinal.mp4"

What to do now?

NooruddinLakhani avatar Oct 06 '20 12:10 NooruddinLakhani

Any update in this? Its working fine on iOS but getting this issue on Android. Any help is much appreciated.

rajesh-rt avatar Sep 12 '22 14:09 rajesh-rt

Same issue

vladimirevstratov avatar Sep 27 '22 17:09 vladimirevstratov

Any help with this?

ol4juwon avatar May 04 '23 17:05 ol4juwon

still facing the issue anyone have any idea please share

crackhack8266 avatar Sep 23 '23 04:09 crackhack8266

crazy same

woowalker avatar Feb 02 '24 02:02 woowalker