I am trying to make a web based audio player and I use firebase storage for keeping audio files. I got problem with storage because firebase doesn't provide http link. Can anyone explaine How i use firebase storage download url or gs path for web based audio player?
Firebase Storage provides a download URL for your files. You can manually get the download URL by clicking on the file, then opening the File Location tab on the right, then clicking on Download URL.
You can get the download URL from your JavaScript with getDownloadURL(). Or you can get the download URL from Firebase Cloud Functions with file.getSignedUrl(). Note that getsignedUrl() doesn't work until you set the Storage Object Creator role for your appspot service account in your Google Cloud Platform IAM & admin permissions page.
It's a 2 step process. First, you upload the audio file.
Second, use cloud functions .onCreate trigger to get, then write the info about the newly added audio file to Firestore (the database). URL shortening can be automated inside this cloud function.
End state is that you have the audio file stored in Cloud Storage and the info about the audio file stored in Firestore.
Related
I have a MERN application and I would like to allow users to upload audio files.
From what I heard storing the files directly in the database or directly in a folder inside the app is not the best option.
What I need is a way to allow users to upload the file, generate an URL, and be able to play that file using the URL after.
What is the best way to do such thing ?
You can make use of Cloudinary. Using their API would allow you upload files and return a URL you can save to your database to use each time you or your users need to access the audio file
I am building a simple static website selling a single pdf file using the Stripe checkout api.
I would like to be able to generate an expiring download link after the customer successfully purchased the pdf.
I am really not sure about how to do this, but I was thinking about using firebase to store the file in a bucket and somehow use a cloud function to generate a temporary download link that expires after some time, but I am not sure how to go about this (or if this is even the best solution).
Can anyone give me some help about which direction to go here?
Firebase'd download URLs don't expire, although you can revoke the from the Firebase console.
But a better fit for your use-case might be to use Cloud Storage's signed URLs, which have a built-in expiration attribute. You can generate these with the Cloud Storage SDKs or Firebase's Admin SDKs, all of which should only be run in trusted environments - such as your development machine, a server you control, or Cloud Functions.
Also see:
A guide to Firebase Storage download URLs and tokens.
Get Download URL from file uploaded with Cloud Functions for Firebase
Recently I am developing an app which connects to firebase and upload important documents to firebase storage.
There are users who will view uploaded documents, so I generated download URL after upload document and stored download url into firebase database so that the app will get download url and use it.
Btw, once generated download url, it is public so anyone can use the link to view the uploaded document on firebase storage.
So I decided to store private url of document into firebase database and then once valid user wants to view the document, the app will generate download url from private url and then use the link to show to the user.
And then right after viewing, I want to revoke download url of the document programmatically on the app.
I see I can manually revoke download url on firebase storage on browser, but I want to do it programmatically on my app.
For security, this is very important.
Can anyone help me?
There currently is no public API to revoke download URLs from Cloud Storage for Firebase. The only way to revoke download URLs is through the Firebase console.
I recommend that you file a feature request.
Related:
Firebase revoke token on download url
Revoking Firebase storage download urls
I am working with google cloud storage transfer service to transfer data from twilio recording url to google cloud bucket. While implementing above thing I came to know that to transfer a file from url you must have a md5 hash of that object.
Now twilio doesn't provide me with the md5 hash value.I wanted to ask is it possible to do above thing and also along with that is there any other way to transfer the content of a url to directly on google cloud bucket.
Also I don't want to use my server for a very long amount of time it has to be quick like schedule so that i can track it or some kind of callback when it will get completed.
Twilio developer evangelist here.
It looks like whatever you do, you're going to need to download the recording files to your own server at some point during this process.
You could loop through the files, download them and generate the md5 hash for each of them, then discarding the file but creating the TSV of URLs and hashes as you go.
But, if you do that, you've done half the work in downloading the file, so you might as well continue to upload the file to Google Cloud Storage from that point, using gsutil or the JSON API.
I just set up a simple JS photo uploader on my site. It uploads photos directly to a Google Cloud Storage bucket.
I used the code from their official JavaScript library
But if you look at that code, you'll see that it requires authentication. I'm authenticated and able to upload photos, but I want everyone to be able to just upload their files without signing in to their Google Accounts.
Is that possible?
You could use a POST policy doc: https://cloud.google.com/storage/docs/xml-api/post-object#policydocument
This will let you build a signed request with various constraints built in (content-length, content-size, etc.), allowing unauthenticated users to upload to your bucket with the given constraints.