Comments (12)
A working example base on 0.8.0-alpha.5
https://github.com/wkh237/rn-firebase-storage-upload-sample
from react-native-fetch-blob.
@dcworldwide , thank you for your information ! I think you might try removing the prefix file:
from the path, and see if it works then 👍
from react-native-fetch-blob.
Related to facebook/react-native#8684
from react-native-fetch-blob.
merged into 0.8.0
from react-native-fetch-blob.
test case reference
https://github.com/w3c/web-platform-tests/blob/master/XMLHttpRequest/
from react-native-fetch-blob.
Awesome work. I've quickly tested out uploading a file to firebase on 0.8.0-alpha.5 but I did have an issue.
07-26 13:41:29.604 3333 3370 I ReactNativeJS: 'Blob', 'verbose:', 'Blob constructor called', 'mime', 'image/png;BASE64', 'type', 'string', 'length', 68
07-26 13:41:29.604 3333 3370 I ReactNativeJS: 'Blob', 'verbose:', 'create Blob cache file from file path', 'RNFetchBlob-file://file:/data/user/0/com.mva/cache/1469504489517.PNG'
07-26 13:41:29.604 3333 3370 I ReactNativeJS: 'Blob', 'verbose:', 'register blob onCreated', 0
07-26 13:41:29.606 3333 3370 I ReactNativeJS: 'Blob', 'error:', 'RNFetchBlob could not create Blob : file:/data/user/0/com.mva/cache/1469504489517.PNG', 'stat error: failed to list path `file:/data/user/0/com.mva/cache/1469504489517.PNG` for it is not exist or it is not a folder'
// create Blob from BASE64 data
let blob = new Blob(RNFetchBlob.wrap(media.url), {type: 'image/png;BASE64'})
// Blob creation is async, start upload task after it created
blob.onCreated(() => {
var metadata = {
customMetadata: {
mediaId: mediaId,
createdBy: user.uid,
},
contentType: 'image/jpeg'
}
var storageRef = firebase.storage().ref();
// Push to child path.
var uploadTask = storageRef.child('media/' + mediaId).put(blob, metadata);
// Pause the upload
// uploadTask.pause();
// Resume the upload
// uploadTask.resume();
// Cancel the upload
// uploadTask.cancel();
uploadTask.on('state_changed',
function (progress) {
// Observe state change events such as progress, pause, and resume
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
var progress = (progress.bytesTransferred / progress.totalBytes) * 100;
console.log('Upload is ' + progress + '% done');
console.log(firebase.storage.TaskState.PAUSED)
switch (progress.state) {
case firebase.storage.TaskState.PAUSED: // or 'paused'
console.log('Upload is paused');
break;
case firebase.storage.TaskState.RUNNING: // or 'running'
console.log('Upload is running');
break;
}
}, function (err) {
blob.close()
console.error(err)
switch (err.code) {
case 'storage/unauthorized':
reject(err)
case 'storage/canceled':
reject(err)
case 'storage/unknown':
reject(err)
default:
reject(err)
}
}, function () {
blob.close()
console.log('Uploaded', uploadTask.snapshot.totalBytes, 'bytes.');
console.log(uploadTask.snapshot.metadata);
resolve(uploadTask.snapshot.metadata.downloadURLs[0])
}
);
I realise this is alpha so there is no point testing it just yet. Just wanted to say I"m really happy your tackling an important problem and am looking forward to using your lib :)
from react-native-fetch-blob.
Ok I'll try that, thanks 👍
from react-native-fetch-blob.
@dcworldwide hey I have also encounter the same issue right now. Can I know if you have resolved it? :)
from react-native-fetch-blob.
right now I am encountering with these error message:
Blob verbose: Blob constructor called mime image/jpeg;BASE64 type string length 34
log.js:24 Blob verbose: create Blob cache file from file path RNFetchBlob-file://[object Object]
log.js:24 Blob verbose: register blob onCreated 0
log.js:36 Blob error: RNFetchBlob could not create Blob : [object Object] failed to list path [object Object]
for it is not exist or it is not exist
and I am using 0.8.0-alpha.6
from react-native-fetch-blob.
@shirleycharlin , I think that's because you're using an object as first argument of Blob constructor.
please refer to the document
from react-native-fetch-blob.
I have resolve it. I actually uses the syntax from Mr @dcworldwide . if you don't mind I would like to copy and paste these code of mine later.
from react-native-fetch-blob.
@shirleycharlin , great to hear that 👍 Please feel free to leave any comment or message.
from react-native-fetch-blob.
Related Issues (20)
- Error calling RCTDeviceEventEmitter.emit failed to create value from json HOT 3
- react-native-fetch-blob has memory leak during update download progress
- Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst; HOT 2
- Could not store file in a specified path HOT 1
- New format of IOS 11 files (HEIF and HEVC) are giving error when uploading
- Invalid value for visibility : 2 HOT 3
- Native module BlobModule is required for blob support HOT 1
- react-native-fetch-blob image upload failed for android(always receives zero bytes)
- Save file to internal storage HOT 4
- Execution failed for task ':react-native-fetch-blob:verifyReleaseResources'. HOT 3
- Does anybody have good example for base64 encoding and decoding for video and image?
- Build is failing due to jcenter dependency disappearing HOT 4
- Cannot download run background in iOS
- Cannot fetch jpeg image multipart/form-data.
- RNFetchBlob blocked firebase/firestore call react native HOT 1
- iOS build failed xcode 10
- android.actionViewIntent not working
- skip some bytes of file in Multipart form-data
- joltup/rn-fetch-blob is absolute SHIT
- RNFetchBlob.fetchBlobForm failed to create request body - Issue happens intermediately HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-fetch-blob.