Is there a way to cache Audio file in flutter app From Firebase - firebase

Hello World
I am building an audio streaming app using flutter and I have all the audio files on firebase storage.
I want to implement the Youtube or Audiomack save offline. in this case, the offline downloaded media file is encrypted so that it can't be found in the device file part.
please I need help from anyone.

you can use this package flutter_cache_manager_firebase which is an implementation for flutter_cache_manager
This library contains FirebaseCacheManager and FirebaseHttpFileService.
You can easily fetch a file stored on Firebase with
var file = await FirebaseCacheManager().getSingleFile(url);
you can always create a custom FirebaseHttpFileService
to cache the data flutter cache manager
CustomCacheManager._() : super(key,
maxAgeCacheObject: Duration(days: 7),
maxNrOfCacheObjects: 20);

Related

Retrieve Firebase storage image without getting downloadurl flutter

How can I retrieve Firebase storage image in flutter without getting downloadUrl and display it within some image compatible widget. I don't want my users to anyhow see download url even if they open my code
If you're using the FlutterFire Storage library in your app, you can call getData on a reference to the file to get its data. So with that you just need to know the path to the data, and you won't need the download URL in your application. Once you have the data locally, you can create an image out of it with: Converting a byte array to image in Flutter?
Unlike download URLs, the call to getData() is checked by security rules, so you'll have to ensure that the user is permitted to access the file.

React Native + Firebase: cache files on device to save bandwidth + make available offline

I'm building a small app for storage of image files- think scans of certificates etc. All stored in Firebase.
Every time I load an image on a screen, Firebase seems to fetch it from my storage bucket, rather than from on the device- even if it's already been loaded on that device. This isn't ideal, seems like it's going to chew a heap of mobile data, and the files need to be available offline.
Am I missing something in my firebase config to set this up- some kind of file caching on device?
There is no local or offline cache for files downloaded from Cloud Storage using the Firebase JavaScript SDK, other than what's provided by the browser when making normal HTTP requests using the normal methods to fetch data from URLs. If you are downloading data using a download URL, then you are depending on the browser to implement any caching.

Firebase Storage clone uploaded file and create new file without downloading/uploading possible?

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));

How can I reference a GCP cloud storage object, from the firebase download link, using the Admin SDK

My question is similar to this: Firebase web: Storage Location from Download URL
I'm writing a firebase function where i need storage location. Right now i have download url:
https://firebasestorage.googleapis.com/v0/b/dxxxxxxxxx.com/o/videosvideo%3A67423?alt=media&token=acxxxxxxxxxxxxxxxxx
Is there a way to get Storage location like this:
gs://dexxxxxxxxxxxxxx.com/videosvideo:67423
The answer given is to do:
const downloadUrl = "https://firestorage.googleapis...";
const gsUrl = firebase.storage().refFromUrl(downloadUrl).toString();
However, the context I'm doing this, is as a Firebase Function - so I need to use the Admin SDK.
The Admin SDK Storage directly references the the GCP Storage Buckets, which don't have refFromUrl().
Is there a simple way to do this? The context is - I want to delete the object for the given download link.
I don't think there is a server side API that's going to do what you want. I'd recommend storing not just the download URL in your database, but also the path to the file in storage. That way, the server can deal with the file easily through the Admin SDK.

Firebase storage - "regardless of network quality"

Reading Firebase's documentation it says that
Firebase Storage provides secure file uploads and downloads for your Firebase apps, regardless of network quality.
But I tried to start an upload without connection and then reconnecting, and it didn't work.
How do I enable offline capabilities for Firebase Storage ? (I already have FIRDatabase.database().persistenceEnabled = true)
Note: I'm implementing an app for iOS in Swift.
Here is the code I'm trying:
FirebaseAPI.storageRef.child("images/test.jpg").putFile(imageURL)

Resources