diff options
| author | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-13 15:20:25 -0400 |
|---|---|---|
| committer | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-13 15:20:25 -0400 |
| commit | c2810d32f5a6234c3b30b2fb709c6fdbab04f0d1 (patch) | |
| tree | f39dfe250922305f028f60a008acc042bfdc2166 /src/actions/firebaseStorage.js | |
| parent | f32d184caca594c71fa7b947ae12ea991b1fc031 (diff) | |
Fixed most bugs and now able to upload file to firebase cloud storage.
Diffstat (limited to 'src/actions/firebaseStorage.js')
| -rw-r--r-- | src/actions/firebaseStorage.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/actions/firebaseStorage.js b/src/actions/firebaseStorage.js index 950dfda..8cdbd59 100644 --- a/src/actions/firebaseStorage.js +++ b/src/actions/firebaseStorage.js @@ -2,14 +2,17 @@ import { storage } from '../firebase.js'; export const UPLOAD_PICTURE = 'UPLOAD_PICTURE'; -export const uploadPicture = (picutreFile, uploader) => (dispatch, getState) => { - var storageRef = storage.ref('requests/' + getState().firebaseAuth.uid + '/' + file.name); +export const uploadPicture = (file, uploader) => (dispatch, getState) => { + if(file) { + var storageRef = storage.ref('requests/' + getState().firebaseAuth.uid + '/' + file.name); - var task = storageRef.put(file); - - task.on('state_changed', function(snapshot) { - var percentage = (snapshot.bytedTransferred / + var task = storageRef.put(file); + + task.on('state_changed', function(snapshot) { + var percentage = (snapshot.bytesTransferred / snapshot.totalBytes) * 100; + console.log(percentage); uploader.value = percentage; - }); -}
\ No newline at end of file + }); + } +} |
