samuelgozi / firebase-storage-lite Goto Github PK
View Code? Open in Web Editor NEWLightweight and performant alternative to firebase storage Js library for modern browsers
License: MIT License
Lightweight and performant alternative to firebase storage Js library for modern browsers
License: MIT License
I was doing my testing with auth turned off, but curious how to use auth with file uploads (i.e. can only upload when logged in). I have a logged in user, but I'm not sure what you mean by pass in the auth object. Any help would be appreciated, thanks!
Rules:
rules_version = '2'; service firebase.storage { match /b/{bucket}/o { match /{allPaths=**} { allow read, write: if request.auth != null; } } }
Hello! This looks awesome, just implemented your Auth package, and so far so good! I'm trying to get this working, but not sure I'm doing it right. Basically trying to make a storage object to work with, but when I do this:
import Reference from 'firestore-storage-lite'; export const storage = new Reference(config.storageBucket);
I get a "Reference is not defined", Rollup says it's missin ga global variable name. Is there any other setup? Would you be able to post a dummy example of setting config and uploading a file? Thanks for the help, can't wait to try it out!
Alright, I got some images uploaded!
So it looks like no progress tracking yet, correct? Any hints for large files, or just keep showing a loading symbol?
var uploadTask = testRef.put(blob); uploadTask.start( function(error) { console.log(error); }, function() { console.log("upload complete!"); } );
That upload function doesn't log anything, seems to work the same as uploadTaks.start(), so I'm guessing we can't pass functions. How do you retrieve the metadata from the promise? Thanks for the help, I love how I can use these libraries without a bajillion errors like the official ones!
I am trying to use the Storagelite
module in my react-native
app to upload a file to firebase storage but it somehow seems to error out. I am using authlite
and firestorelite
(with integrated auth) with no issues at all. I am signed in when i issue the request so it isn't a problem with authentication. Since i use Firestorelite with auth, there really is no integration problem since i use the same approach here.
My code:
import Storage from 'firebase-storage-lite';
import { firebaseConfig } from '../../configs/firebase';
import { MediaDataIF } from '../../contexts/CreatePostsContext';
import { auth} from '../'
const bucket = new Storage(firebaseConfig.storageBucket, auth);
const fbStorageUploadMedia = async (mediaObject: MediaDataIF) => {
const blob = await fetch(mediaObject.path).then(res=>res.blob()); //the mediaObject i get is a JSON and i haven't figured out an optimal/easy way to convert that to a `Blob` in react-native and thus the `fetch`.
console.log("blob ",blob); //see attached screenshot of DevTools console.
const upload = bucket.put(blob);
console.log("upload ",upload); //see attached screenshot of DevTools console.
upload.then(meta => {
console.log(meta);
});
upload.catch(e => {
console.error("ERROR IN UPLOAD ",e); // see error below
});
upload.finally(() => {
console.log('done or failed');
});
}
The error i get is:
ERROR IN UPLOAD TypeError: Network request failed
at fetch.umd.js:527
at JSTimers.js:235
at _callTimer (JSTimers.js:130)
at Object.callTimers (JSTimers.js:383)
at MessageQueue.__callFunction (MessageQueue.js:416)
at MessageQueue.js:109
at MessageQueue.__guard (MessageQueue.js:364)
at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:108)
at debuggerWorker.cff11639.js:4
Screenshot:
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.