Is there a way to get all the images(files) from firebase storage. It doesn't have the listall() function in flutter. If there isn't way to do this, can we get images by their metadata? I don't want to get them by their names.
Until proper file listing gets added to the API, you don't really have a way to do this from Flutter. Your best options are to:
Build a backend endpoint that can use one of the server SDKs to list objects from Cloud Storage. Query that endpoint from your app.
Make a record in a database for each file, and query the database instead. Make sure to keep the bucket and database in sync.
Related
I am confused as to how to connect to my Firebase DB using, say Postman to send the REST requests.
In the screenshot below, you can see my DB structure and GET request.
Specifically, the GET request in Postman looks like this,
https://fir-crud-api-b1cec.firebaseio.com/products/test.json?auth=xxxx
while the DB is structured as such
products > test.json
Would appreciate any advice to point me in the right direction. Thanks!
Your URL suggests that you want to use the Realtime Datbase REST API, but your screenshot suggests that your data is in Firestore. These are different databases with different APIs.
If you want to work with data in Firestore, you should use the Firestore REST API instead.
The screenshot on the left shows the Cloud Firestore database, while in PostMan you are trying to access the Realtime Database. While both databases are part of Firebase, they're completely separate, and have completely separate REST APIs.
If you want to access Cloud Firestore from PostMan, have a look at its REST API. Fair warning that this API is significantly more complex than the one for the Realtime Database.
If you want to continue using the Realtime Database REST API, make sure to create your data structure in the Realtime Database in the Firebase console.
let's say I have an image /path/image1.png in the firebase storage. I want to copy this image and create a new image with a different name but the same content as /path/image2.png. I'm using AngularFire. How will I achieve this? Please help
Firebase Storage (nowadays called Cloud Storage for Firebase) is a set of client-side SDKs that allow you to access Cloud Storage from within your application.
There is no Firebase API to create a copy of a file in Cloud Storage. It's a valid use-case though, so I'd recommend you file a feature request for it.
In the meantime, the two options I can think of are:
Read the data to the client, and write it to the new location. This is definitely wasting bandwidth for the client, so I'd only consider it if your files are quite small, and your clients have a decent connection.
Use one of the (non-Firebase) server-side SDKs for Cloud Storage to create a copy of the file. For example, you could wrap this Node.js code in a callable Cloud Function and then call that from your application code.
await storage
.bucket(srcBucketName)
.file(srcFilename)
.copy(storage.bucket(destBucketName).file(destFilename));
I'm using Realtime Database in Firebase and by accident I clicked on Cloud Firestore. Since then whenever I want to access Realtime Database it defaults to Cloud Firestore and I have to click and choose the database I'm using, super annoying. Is there a way to disable or delete it?
Is there a way to disable or delete it?
There is no way you can disable either Cloud Firestore or Firebase realtime database from your Firebase console. The simplest solution I can think of, is to save a bookmark in your browser pointing to:
https://console.firebase.google.com/project/firebaseProjectId/database/yourProjectName/data
You can also copy and paste the url that you need and it will point directly to your Firebase realtime database project. In this way you'll skip the initial steps.
I am planning to use firebase storage as storage bucket for images for my app.
Shall I use client side firebase SDK to upload images directly to firebase or, shall I send image to my server first and use firebase Admin-sdk and let the server upload image to firebase? Also I have other data along with image which client will send, that server needs to handle.
EDIT: I was confused about one thing, if I use firebase admin-sdk, first my image need to upload to the server and then server will send it to firebase storage, won't it double the upload time?
Both are valid options, and neither is pertinently better than the other.
I typically prefer using the Firebase SDK to upload to Cloud Storage, since it saves me from having to come up with my own client-side code and handling things like network detection, retries, etc. I then often write metadata about the file to the Firebase database (either the Realtime Database, or Cloud Firestore) and use that to trigger Cloud Functions to do any backend processing that is needed on the image.
But it's equally valid to write your own server-side endpoint that does the processing of the image, and post to that from within your app.
I'm writing firebase android app in android studio. I have almost 2000 geo locations and I want them to be marked on map all the time. Firebase databse isn't good idea to store such data because this is static data. So firebase storage, hosting, just some list in code or something different would be the best way?
Thanks in advance
For static data, you could use list and append all the geo locations with push() method. The push() method generates a unique key every time a new child is added to the specified Firebase reference.
By using these auto-generated keys for each new element in the list, several clients can add children to the same location at the same time without write conflicts. The unique key generated by push() is based on a timestamp, so list items are automatically ordered chronologically.
For static data that you create yourself, I'd use Firebase Hosting. It gives you a simple way to update the data with firebase deploy, and comes with a built-in CDN.
For unstructured data that your users create, use Cloud Storage for Firebase.
For structured data that your users create, use Cloud Firestore or the Realtime Database.
Also see: Firebase : Differences between realtime database and file storage