Change uri to url?

1,026 views
Skip to first unread message

HalesEnchanted

unread,
Jun 11, 2016, 8:00:13 PM6/11/16
to Firebase Google Group
Hi There,

I'm Haley. I just started using Firebase and I'm absolutely loving it even though I'm a bit stuck at the moment. I'm using it with node js, and I have successfully uploaded to the storage with Google Cloud, the only issue is even though the url is right in Google's actual storage, in Firebases', it is just a uri?

For example: gs://urlofmine.appspot.com/photos/XIII8041-800x800.jpg

Three questions:
1. What do I do to ignore files that already exist instead of overwriting them?
2. How do I have "File Location" in Firebase show a full URL as opposed to a URI?
3.  If the above question isn't possible, how do I retrieve the URI with Node? 

Code I'm using:

    request('http://asset.beyonce.com/wp-content/uploads/2016/06/XIII5022.jpg').pipe(bucket.file('photos/' + filename).createWriteStream(
     {metadata: {contentType: 'image/jpeg'}}))

Mike Mcdonald

unread,
Jun 16, 2016, 12:52:06 AM6/16/16
to Firebase Google Group
Hi Haley,

Welcome, glad you're enjoying using Firebase :)

Seems like this is somewhat related to http://stackoverflow.com/questions/37824361/generate-download-url-after-successful-upload (which I believe you also asked), though it does ask some different questions, so I'll answer those here.

1) You can write a security rule to prevent the overwrite (disallow write if there's an existing file), which is probably the best solution. You can also enable object versioning so that old (overwritten) versions aren't "deleted".
2,3 ) Using Firebase Storage clients (Android, iOS, web JS), you can call getDownloadURL(), using gCloud, you call getSignedURL(), which does an equivalent thing (see this SO post for more info).

Thanks,
--Mike
Reply all
Reply to author
Forward
0 new messages