Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Storage Doesn't Work w/React Native #5

Closed
aaronksaunders opened this issue Jul 11, 2016 · 3 comments
Closed

File Storage Doesn't Work w/React Native #5

aaronksaunders opened this issue Jul 11, 2016 · 3 comments

Comments

@aaronksaunders
Copy link

aaronksaunders commented Jul 11, 2016

I believe this is an issue in React-Native's implementation of the binary upload, but I will start here since I am getting an error message back

error {"code":"storage/unknown","message":"Firebase Storage: An unknown error occurred, please check the error payload for server response.","serverResponse":"Multipart body does not contain 2 or 3 parts.","name":"FirebaseError"}

Code

var fileRef = firebase.storage().ref('images/sample-text')
var uploadTask = fileRef.put(new File(['this is a small amount of data'], 'sample-text.txt', { type: "text/plain" }), { type: "text/plain" });

uploadTask.on('state_changed', function (snapshot) {
    console.log('state_changed', snapshot);
}, function (error) {
    console.log("error", JSON.stringify(error));
}, function () {
    // Handle successful uploads on complete
    // For instance, get the download URL: https://firebasestorage.googleapis.com/...
    var downloadURL = uploadTask.snapshot.downloadURL;
})

I see the same issue on IOS/Android... goes into the Firebase source and then it is over...

BTW the code works in regular reactJS

See here... https://jsfiddle.net/Aaronksaunders/69z2wepo/48545/

@davideast
Copy link
Owner

Hey @aaronksaunders,

This unfortunately is a known limitation of Firebase Storage.

React Native operates in a Node.js environment and Firebase Storage only supports File and Blob types which are browser dependent.

Check the blog post for more info: https://firebase.googleblog.com/2016/07/firebase-react-native.html

@yaronlevi
Copy link

+1 It is really unfortunate that Firebase on React Native dose not support uploads.

@aaronksaunders
Copy link
Author

@yaronlevi https://github.com/aaronksaunders/Firebase3-ReactProject
it can be done with some magic of plugins and polyfills...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants