Firebase Storage and Glide - Signature - firebase

When using glide to load images from firebase storage, is there a possibility to check metadata of the file to make sure that the current cached edition is not outdated? In my usecase, i sometimes update files within a static reference. This used to be an easy option for me until caching of glide came into play. It keeps showing the cached version, not knowing that theres new data in storage under that ref.
I know that i can switch off caching. What i would like to achieve is to check metadata first and then load from cache if the data is still current. I have seen the .signature option in glide an was wondering if it is working somehow with firebase but couldnt find anything.

There is no simple configuration for this. You will have to write code that uses the Firebase SDK to get the metadata and check it yourself. Based on the result of that, you will then have to use Glide's API to invalidate the cache as needed. I'm sure it will be a non-trivial amount of code.

Related

Flitter Firebase multi language

I'm developing an application using Flutter and Firebase.
I need to support multiple languages and I was wondering about what is the best solution to do that... Can I keep the strings in Firebase and fetch them without downloading them each time I need?
When the user select a language the first, usually it does not change, but sometimes it could.
Thanks!
I can't understand why you want to use multi-languages feature using Firebase.
In any app at least there are static texts.So at least for that part you don't need the translation stored in the Firebase (performance issue). I suggest to have a look at this package easy_localization : https://pub.dev/packages/easy_localization
Why you should use static translation:
when using non static translation (downloaded from Firebase) :
You have to download the translations : App does work only if connected to network (at least first time or after user clear the cache of the application)
You have to cache the result : using shared_preferences
You have to fetch the translations from cache every time.
If you still insist about using Firebase.You can see a similar question for android (answered by GDE): Firebase Multi-Language support: Is possible?

Does admin.storage.object contain/process multiple files if multiple files are uploaded to Firebase Storage?

I am trying to move files into separate folders in Firebase Storage once they have been uploaded. As it turns out, you can not achieve this with the the JavaScript Web Client SDK for Storage. However, it appears that you could do so with the Admin SDK for Storage using Firebase Functions. So that is what I am trying to do. I understand that you need to first download a file into your Firebase Functions and then re-upload into a new folder in Storage.
To download a file, I need to pass its reference from the client and here is where it gets confusing to me. I am currently getting all the uploaded files in the client via the listAll() function which returns items and prefixes. I am wondering whether or not I can use either the items or the prefixes to then download the files into Firebase Functions using them (items or prefixes). Alternatively, I can pass the URLs. However, the question is, which method do I use to get and download them in Functions afterwards?
I know of admin.storage.object as explained in https://firebase.google.com/docs/storage/extend-with-functions#trigger_a_function_on_changes. However, does it handle multiples files? In other words, the object, as I understand, is one file that is uploaded to Storage and you can use its attributes such as object.bucket or object.name to access more information. However, what if there are multiple files uploaded at the same time, does it handle them one by one? Also, if I am passing the references or URLs of the files that need to be downloaded from the client, is admin.storage.object the right choice? Because it seems to simply process all the files uploaded to Storage, instead of getting any references from the client.
Further, there is a description of how to download a file (https://firebase.google.com/docs/storage/extend-with-functions#example_image_transformation) which is this code: await bucket.file(filePath).download({destination: tempFilePath});
I understand that the filepath is basically the name of the file that is already in Storage (ex. /someimage). But what if there are other files with the same name? Might the wrong file be downloaded? And how do I make sure that the filepath is the file that I passed from the client?
Let me know what your thoughts are and whether or not I am heading in the right direction. If you include a code in your answer, please write it in JavaScript for the Web. Thank you.
Thank you!
Here are some points that could help:
In GCP Storage technically there are no folders, GCS emulates the directory structure by using / in the names of objects.
When setting a cloud function triggered by a GCS object change, each object change is an event, each event triggers an invocation of the function (you might have an bucket for unprocessed files which triggers the function and have them move to a different bucket when proccesed)
You might consider using the REST API to move/copy/rename the objects without having to download them
As a side note the question is a little too broad, possibly these points could help clarify things for you.

Point dynamic the Firebase database

I would like to build a simple framework on Flutter + Firebase, but unfortunately I have a big problem.
Construction of the framework makes sense when you can dynamically point any database in the application downloaded from the store (each customer has a different database, but the application in the store is one).
Unfortunately, from what I understand, the connection data to Fierbase must be in the google-service.json file in the source code.
Is there any way to point dynamic the Firebase database?
google-services.json is not required to initialize Firebase. You can take control of initialization by calling FirebaseApp.initializeApp() on your own with the values you specify. You can also use the Play services documentation to help.

Change realm file without restarting app

I'm using realm with iCloud document, so question:
How can I change realm file without restarting app when iCloud document changes?
You should never change a Realm file while it is opened by a Realm object. This could end in unknown side effects.
So I would recommend to export the realm file whenever it makes sense. This file could be synced via iCloud and also be monitored for changes - to import the changes.
Exporting method explained the docs: https://realm.io/docs/swift/latest/api/Classes/Realm.html#/s:FC10RealmSwift5Realm15writeCopyToPathFS0_FTSS13encryptionKeyGSqCSo6NSData__GSqCSo7NSError_
If the realm file is larger there is another disadvantage: iCloud would always sync the whole file even for smaller changes.
In short: It feels complicated to implement a clean, conflict free syncing solution using Realm and iCloud. Maybe you should think about using CloudKit or any similar backend service to realize your data syncing:
https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/CloudKitQuickStart/Introduction/Introduction.html

Initialization of local sync store in Azure's offline-sync API

I'm working with Azure's offline-sync API.
(It's REALLY GREAT so far, but since it's still new-ish it doesn't have comprehensive documentation, only tutorials. We need to craft dependable integration tests, and we're finding that tricky because we need to rely on published behavior in official docs for that... or dig into the source, but that is liable to change at any time.)
The samples do this:
var store = new MobileServiceSQLiteStore("localstore.db");
The comments mention "initializes local store".
I assume the local sync database is a "throw-away" asset, as it can be recreated at will.
Is the expected behavior that it will create the local SQLite file if it does not exist, or it will recreate the file each time the mobile app starts and that call is made?
The tutorials are augmented by the HOWTO documentation (available under Mobile > Develop - in the same area as the tutorials) and the GitHub Wiki and the github.io pages for the SDK.
The local store is created if it doesn't exist, and new fields are added to tables if they are needed. It's sometimes good to delete the database - for example, if you reduce the field count in your mobile app (the process only adds fields). If you do this, the database will be re-created when the app is next restarted.

Resources