RNFS.uploadFiles [Error: unexpected end of stream] framesToPop: 1, code: 'EUNSPECIFIED'
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?
Could you use Android studio to get the log so I can inspect it, thank you!
Check your file paths. Could you provide the log of this console.log('check url', url, files)?
@cafeasia3 did you solve your issue?
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' }
My url was wrong ;)
sampe problem
@aliazizi Can you provide a log as RichardLindhout have provided? So I can research this bug.
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
@aliazizi hey, can you send example code.
@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
I am also getting the same error. I am not getting the real Path of file.
Someone, please help
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?
Any update in this? Its working fine on iOS but getting this issue on Android. Any help is much appreciated.
Same issue
Any help with this?
still facing the issue anyone have any idea please share
crazy same