philippkrone / react-native-fileupload Goto Github PK
View Code? Open in Web Editor NEWMulti-form file upload for react-native
License: MIT License
Multi-form file upload for react-native
License: MIT License
@PhilippKrone - Where to keep the file which is to be uploaded?
In Below documentation, what does absolute path means? Where to keep the file? '/' refers to which root folder - apps root folder( where index.android.js resides) OR to mobiles handset file system?
files: [
{
name: 'one', // optional, if none then filename
is used instead
filename: 'one.w4a', // require, file name
filepath: '/xxx/one.w4a', // require, file absoluete path
filetype: 'audio/x-m4a', // options, if none, will get mimetype from filepath
extension
},
]
In my code, I kept png file in apps root folder, and used following code but it gives above error.
filename: 'favoriteFilled.png',
filepath: 'favoriteFilled.png',
I have tried giving filepath as:
'filepath: '/favoriteFilled.png',
'filepath: './favoriteFilled.png'
But, still same error I get.
when upload some files the APP freeze until upload is done.how to fix it?
why I am getting this error?
I'm using RN 0.21 and am getting this error:'Coulnd't find key fields in dynamic object'. The code works well in iOS--any suggestions?
the filepath is correct and err is null,but why data is null?
any idea?
#Feature Request
I would love to see this updated and supported for react 0.60 >
#Why it is needed
I have an older app who uses this library, and always thought it was great, but can't use it anymore when upgrading react.
Hi,
Is this repository working with current versions of react-native/android/ios?
Thanks
Using RN 17. Below is the code.
var obj = {
uploadUrl: 'http://makeuroffer.s3.amazonaws.com',
method: 'POST', // default 'POST',support 'POST' and 'PUT'
headers: {
//'contentType': 'image/jpeg',
'Accept': 'application/json',
},
fields: {
"acl": "public-read" ,
"Content-Type": "image/" ,
"key": 'biz/' + 'third.jpg' ,
"x-amz-meta-tag": '' ,
"x-amz-meta-uuid": "14365123651274",
"bucket": 'makeuroffer' ,
"x-amz-algorithm": "AWS4-HMAC-SHA256" ,
"x-amz-credential": data.key + "/" + moment().format('YYYYMMDD') + "/" + 'us-west-2' + "/" + 's3' +"/aws4_request" ,
"x-amz-date": data['x-amz-date'] , //'20160112T105326Z'
"policy": data.policy,
"x-amz-signature": data['x-amz-signature']
},
files: [
{
//name: 'filename', // optional, if none then filename
is used instead
filename: 'more.jpg', // require, file name
filepath: pic.uri, // require, file absoluete path
//filetype: 'audio/x-m4a', // options, if none, will get mimetype from filepath
extension
},
]
};
FileUpload.upload(obj, function(err, result) {
debugger;
console.log('upload:', err, result);
});
Anybody know why could be this error, when trying to upload on Android?
undefined is not a function (evaluating '_reactNativeFileupload2.default.upload')
Thanks!
My uri is 'assets-library://asset/asset.JPG?id=ADDB18BD-F81E-4C64-BB05-D994F0D53F8D&ext=JPG'
How can I upload image by this
Thanks
When I added "compile project(':react-native-fileupload')" to gradle.build
and tried to gradle sync, I've got this error below.
"Gradle 'android' project refresh failed
Error:Configuration with name 'default' not found."
If I delete [compile project(':react-native-fileupload')] line, build passes.
When I tried to clean the build, I got more specific message like below.
"Error:A problem occurred configuring project ':app'.
Cannot evaluate module react-native-fileupload : Configuration with name 'default' not found."
I'm using react-native 0.14.0-rc
:react-native-fileupload:mergeReleaseResources
:react-native-fileupload:processReleaseManifest
:react-native-fileupload:processReleaseResources
:react-native-fileupload:generateReleaseSources
:react-native-fileupload:processReleaseJavaRes UP-TO-DATE
:react-native-fileupload:compileReleaseJavaWithJavac
.../node_modules/react-native-fileupload/android/src/main/java/com/yoloci/fileupload/FileUploadModule.java:23: error: package com.facebook.internal does not exist
import com.facebook.internal.BundleJSONConverter;
react-native 0.37.0
Followed this step and stuck at this error. i am checking this module on ios.
For example:
Sending the field:
fields:{
'data' : JSON.stringify( { 'info' : { 'name': "Còmplex Nâmïng" } } )
}
Make some characters get lost due to the writeBytes conversion in FileUploadModule.java#102 file. This can be solved as I did in the PR #35.
I send three images to my server with this code:
var obj = {
uploadUrl: Globals.BASE_URL + Globals.API_PATH + q,
method: 'POST', // default 'POST',support 'POST' and 'PUT'
headers: {
'Accept': 'application/json',
'Authorization': 'application/galickho',
},
fields: {
email:"[email protected]",
},
files: this.state.images
};
console.log(obj.files); // This is correct: 3
FileUpload.upload(obj, function(err, result) {
console.log('upload:', err, result);
if(err != null){
reject(ErrorManager.getError("http_error"));
}else{
resolve(result);
}
})
And my server returns the contents of the $_FILES variable. If I sent images from an iOS device, my server returns three images. But if I have sent the images from an Android device, only it returns the last image...
Simple PHP Code:
echo json_encode($_FILES);
Device: ACER A3-A20FHD
Android OS: 4.4.2
RN ver. 0.31
RN Cli ver. 0.2.0
Plugin ver. 1.2.0
Doesn't send cookies with request.
Thx
Hi!
I'm trying to upload an image on android with this code:
var obj = {
uploadUrl: config.API_URL + 'images',
method: 'POST',
headers: {
...config.HEADERS,
'Authorization': 'Bearer ' + this.userToken
},
fields: {
'one': 'two'
},
files: [
{
name: 'file',
filename: 'avatar.jpg',
filepath: this.avatarSource.uri
}
]
};
FileUpload.upload(obj, (function (err, result) {
//err === 'Error happened: Precondition Failed'
}).bind(this));
And I'm receiving this error. Do you have any ideas why does it happen?
Thanks!
The Android implementation has a hardcoded value for 'name', which is contrary to the documentation and to the iOS implementation. The 'name' parameter passed is ignored.
Although #26 addresses this, it does not follow the behaviour of the documentation, namely:
// optional, if none then
filenameis used instead
hi,i use commad "react-native run-android",then failed...
react-native : 0.16.0
log:
:react-native-fileupload:compileReleaseJavaWithJavacF:\apowo\PTuApp\client\truck\P2_16\node_modules\react-native-fileupload\android\src\main\java\com\yoloci\fileupload\FileUploadModule.java:23: ▒▒▒▒: ▒▒▒▒▒com.facebook.internal▒▒▒▒▒▒
import com.facebook.internal.BundleJSONConverter;
I do not know Why...
i have a doubt that how to upload an image to amazons3 with this, For upload an image can i use this repo, if possible how to use it
I can't upload image binary in android.
here is my android file path
constructor(props) {
super(props);
this.state = {
avatarSource: null,
videoSource: null
};
var obj = {
uploadUrl: 'http://192.168.50.161:8080/soledede/image',
method: 'POST', // default 'POST',support 'POST' and 'PUT'
headers: {
'Accept': 'application/json',
//'Accept': 'multipart/form-data',
//'Content-type': 'multipart/form-data'
//'Content-Disposition': 'form-data; name="file"',
},
fields: {
'hello': 'world',
},
files: [
{
name: 'image', // optional, if none then filename is used instead
filename: '1007044', // require, file name
filepath: 'content://media/external/images/media/1007044', // require,
filetype: 'image/png,image/gif,image/jpeg',
},
]
};
FileUpload.upload(obj, function (err, result) {
console.log('upload:', err, result);
});
}
there is my debug in chrome
image
what's like the android file path ,can show me a example
How can I deal with it in android
Thanks
soledede
I am using xcode emulator to test, I installed camer-roll-picker to pick and get image path and name . In Xcode for one of camera roll image , details are as follows:
filename: 'IMG_0005.JPG',
filepath: 'assets-library://asset/asset.JPG?id=ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED&ext=JPG'
I tried above, and I tried localhost e.g. http://localhost:8888/photos , I do not see a pic, Its my 3rd day but i did not have any idea what absolute path stands for in this context. I also tried putting images under app files folder wherever possibly I can . none worked.
these other spinoffs have progress reporting:
https://github.com/aroth/react-native-uploader
https://github.com/wootwoot1234/react-native-transfer
but yours is the only one with Android support. There's like 4 main packages all based on the original code by @booxood . I wonder how we can unify them.
Hey there,
i would love to use this but i get following error:
node_modules/react-native-fileupload/android/src/main/java/com/yoloci/fileupload/FileUploadModule.java:23: error: package com.facebook.internal does not exist import com.facebook.internal.BundleJSONConverter;
Is it possible to upload video ?
I'm trying to upload on S3, everything is working but when I download my file again I can't open it. The file seems broken.
Do you have any idea ?
var obj = {
uploadUrl: options.uploadUrl,
method: 'POST',
headers: {},
fields: {},
files: []
};
NativeModules.FileUpload.upload(obj, function(err, result) {
if (result && result.data === 'ok') {
handleRight()
} else {
handleError();
}
});
in FileUploadModule.java/upload
fileInputStream.close();
this line will crash as i pass an empty files array, I think maybe here should have a judge if files array is empty
Thanks for this plugin! It looks like there are a few issues and PRs that could use attention though. Is it possible to add a maintainer in order to get the PRs sorted out? Or perhaps to think about merging this + PRs into one of the other fs modules? I'd be glad to volunteer.
Ref: #9 #15 #20 and timsuchanek#1
upload: Error happened: exceeded content-length limit of 180945 bytes null
I am trying to upload a image from FileSystem, which is jpg Format. But i get the RedBox Message "could not invoke FileUpload.upload"
This is my code:
var FileUpload = require('NativeModules').FileUpload;
var UIImagePickerManager = require('NativeModules').UIImagePickerManager;
UIImagePickerManager.showImagePicker(options, (didCancel, response) => {
console.log('Response = ', response);
if (didCancel) {
console.log('User cancelled image picker');
}
else {
fileName = response.uri.substring(response.uri.lastIndexOf("/") + 1);
fsPath = response.uri;
var binaryResponse = response.data;
const obj = {
uploadUrl: API_URL + 'user/avatar',
method: 'POST',
headers: {
'Authorization': AuthStore.getUserTokenWithBearer()
},
fields: {
'hello': 'world',
},
files: [{
filename: 'image', // this is what your server is looking for
filepath: response.uri, // uri from response (local path of image on device)
filetype: 'image/jpeg'
}]
};
FileUpload.upload(obj, (err, result) => {
console.log('upload:', err, result);
});
}
});
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.