Accessing Files from Firebase Storage vs Firebase Hosting? - firebase

So here is the scenario:
When I access files from Firebase Storage:
I get my file from storage bucket(.html, .png, .zip etc) (Small in size btw no more than 2mb).
Store that file in my local storage so the app don't need to download it again and consume the bandwidth of the server.
Use it from local storage everytime the app needs it.
When I access files from Firebase Hosting:
I get my file from nearest CDN of Firebase(.html, .png, .zip etc) (Small in size btw no more than 2mb).
Store that file in my local storage so the app don't need to download it again and consume the bandwidth of the server.
Use it from local storage everytime the app needs it.
NOTE: I also have one file version.txt on storage bucket (Firebase Storage). According to the value in this file, I decide whether to fetch file in Step 1 again or not. It means the version.txt is fetched everytime.
Questions:
How to achieve the similar version programming part in Firebase Hosting? I know we deploy folders, can we get their version from Firebase CDN. If yes, how?
In which method I gonna first hit my LIMIT as we know Firebase is paid after a limit.
Pros of Hosting: It will be faster. Link
PS:
1. My concern is bandwidth and not security.
Currently, I am using basic Plan (free) with limits Source:

From the Firebase docs:
The Firebase Realtime Database stores JSON application data, like
game state or chat messages, and synchronizes changes instantly
across all connected devices.
Firebase Remote Config stores
developer-specified key-value pairs to change the behavior and
appearance of your app without requiring users to download an update.
Firebase Hosting hosts the HTML, CSS, and JavaScript for your website
as well as other developer-provided assets like graphics, fonts, and
icons.
Cloud Storage stores files such as images, videos, and audio as well as other user-generated content.
Storage has higher free tier limits, while Hosting might be a little faster. Note that all files on Hosting are publicly accessible, so if you need authentication or authorization, you should use Storage.

Related

How to synchronize files from firebase storage to app's assets folder?

still new to flutter and firebase. I understand how to store and retrieve images and display it on the app.
But how do I go about synchronizing files from the app's local asset folder to an asset folder stored in firebase storage? My intention is to check the cloud folder if a new image like an icon is recently uploaded, and download it to the app's local folder. If a file is removed in the cloud storage, it should also remove it from the local assets folder, mirroring it.
I need a way to compare local AssetManifest.json to the one on firebase storage. I Just need a little direction/algorithm to start with. Thanks for the help!
There is nothing specific built into Cloud Storage's Firebase SDK for this, so you'll have to build it in your own application code.
Using only the Cloud Storage for Firebase API
If you're just using Cloud Storage, you'll have to:
List all files that you're interested in from Storage.
Loop over the files.
Get the metadata for each file and check then the files was last updated
Compare that to when you wrote the local file.
Download the file if it is new or modified.
This approach will work, but it requires quite some calls to the Storage API, because there's no specific API to give you files that were modified since a specific date/time.
Storing metadata in a cloud database
You could also consider storing the metadata in a cloud database, like Firebase's Realtime Database or Cloud Firestore, and then use the query capabilities of that database to retrieve only files that were modified since your device last synchronized.
The recipe then becomes:
Determine when we last synchronized, which is a value you'll want to store in local storage/shared preferences.
Execute a query to the database to determine which files were added/modified since then.
Loop over the query results and...
Download each file that was modified.
In here, only step 2 and 4 make calls to the external APIs, so it is likely to be faster and cheaper to execute (but more work for you to write initially).

Mirror Firebase Cloud Storage Directory to a Dropbox Directory

I'm very new to using Firebase Cloud Storage. I'm currently using it to store data generated by some in-house tablet apps. We want users to be able to easily access this data in the form of Dropbox, however don't want to integrate the Dropbox API into our tablet applications as we're already using Firebase for all login management, etc and don't want users to have to login twice.
Is it possible to setup of a mirror between Firebase Cloud Storage and a Dropbox account such that any file added to Firebase Cloud Storage is immediately copied to the Dropbox directory?
You can simply use cloud functions which are being triggered by cloud storage service (it will triggered on any uploading, updating, deleting files or folders) on your firebase project and then write your cloud functions in a way to use dropbox api and then make the same change in the dropbox directory structure.
Cost and performance wise I don't think it would an efficient thing to do, unless it is what really you want.

In Ionic or cordova platform, how to sync and retrieve database from iCloud

I have build an app using ionic framework, and the data uses sqlite database and stores in app /documents folder.
Now I want to know is it possible to sync the database into iCloud, so the user can retrieve the data automatically if they reinstall the app or use a new device.
I did search for some solution, some suggest sync to remote database using such as pouchDB or parse. But as for our company policy, we cannot store app data into any other remote place exclude iCloud.
Any ideas? Thank you so much.
As far as I know, iCloud automatically backs up data on the user's local storage. You don't need to do anything extra.
I might be wrong, but soome people seem to have problems with it doing that
Check out this page
Relevant:
BackupWebStorage(string)
Default: cloud
Allowed values: none, local, cloud.
Set to cloud to allow web storage data to backup via iCloud. Set to local to allow only local backups via iTunes sync. Set to none prevent web storage backups.

How many files can I upload at once to Firebase Hosting?

We're thinking about using Firebase Hosting (which is awesome: ssl, control over redirects, easy CLI tool, etc) to host our API docs. Currently, we count 17k files generated. We did a test upload, and everything worked (pretty cool!). We're curious, is there a limit to the number of files we can deploy to Firebase Hosting?
I'm not aware of a limit on the number of files. But they zipped result (which is what actually gets uploaded) definitely has to be less than 2GB.

Image upload with s3fs and application performance

I am developing a web application in ASP.NET 4.5. One part of the application includes the user the option to upload images. The images are stores on Amazon S3. Right now the pathc I though about choosing is to use Amazon SDK to upload the images to the bucket on S3 and server them via CloudFront. The thing is that I think that using s3fs might be a better option.
If I mount an S3 bucket as a folder, when the user upload a photo, I can continue the application operation, knowing that the image will be transferred via the network to S3, so I don't need to wait until this process completes before continuing the code. So all I have to do is to wait until the image finished uploading to the server and continue the code.
I want to know if this a good way to do this. Waiting for images to upload can take time and I don't want the user to wait until all the images have been uploaded, which can take some time.
Any suggestions for the best implementation of image uploading?
That is a suitable approach if you will be having multiple application servers which need to interact with a single bucket. You might want to consider configuring s3fs to use a local storage directory as cache, so as to improve performance, as writing directly to your s3fs mount will typically take longer than to local storage.

Resources