-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(storage): add the getBlob and downloadFile methods #665
Comments
I like the idea, but using base64 leads to an out-of-memory exception with "large" files. For this reason, I always recommend interacting directly with the native file system (see this blog post). I'm not sure whether it's a good idea to make this API available to Capacitor developers. But feel free to create a PR and I'll take a look at it. |
Good point. |
Yes, that's a good point. I would probably merge the feature and wait and see what the feedback from the community is like. |
@robingenz, maybe an alternative solution to fix the security issue is to use the "download to a local file" functionality available on Android & iOS. Android: https://firebase.google.com/docs/storage/android/download-files#download_to_a_local_file We can have a "getFile()" method that has a call signature similar to the "Filesystem.writeFile()" method's interfaces (WriteFileOptions & WriteFileResult). What do you think of this solution ? |
That is much better. However, I would probably prefer to call the method
I suggest the following for the call signature: export interface DownloadFileOptions {
/**
* The full path to the file to download, including the file name.
*
* @since 6.2.0
*/
remotePath: string;
/**
* The uri to the local file, including the file name.
*
* @since 6.2.0
*/
localPath: string;
}
@mamillastre What do you think? |
Seems perfect ! To be consistent with the Storage plugin and the Filesystem plugin, we can also have: export interface DownloadFileOptions {
/**
* The full path to the file to download, including the file name.
*
* @since 6.2.0
*/
path: string;
/**
* The uri to the local file, including the file name.
*
* @since 6.2.0
*/
uri: string;
} I will update this feature request. For now, I do not have the time to work on this. But maybe later. |
You're right, that's better. |
Plugin(s)
Current problem
The plugin allows to get the download URL of a file.
But if we protected a file with a rule, it may be useful to have another way and avoid generating a public link.
Preferred solution
In the firebase web sdk, we have the getBlob method to directly get the file as Blob.
On Android & iOS, the app can crash if we download the file in memory (see https://capawesome.io/blog/the-file-handling-guide-for-capacitor/).
For these native platforms, we can use the "download to local file" functionality.
So we can add a "getBlob()" method (only on web) and a "downloadFile()" method (only Android & iOS).
Alternative options
No response
Additional context
Firebase doc:
Before submitting
The text was updated successfully, but these errors were encountered: