flutterfire
flutterfire copied to clipboard
[FIREBASE_STORAGE] Flutter WEB : mime/contentType defaults to application/octet-stream after upploading files to firebase storage if contentType is not provided in settableMetadata
Is there an existing issue for this?
- [x] I have searched the existing issues.
Which plugins are affected?
Storage
Which platforms are affected?
Web
Description
On flutter web, same issue fixed on android by https://github.com/firebase/flutterfire/issues/12363 and https://github.com/firebase/flutterfire/issues/12801
On Web, putFile function is not available (only compatible with android), so you have to use putData instead on a firebaseStorageRef.
When you FirebaseStorage.instance.ref().child(fileName).putData() with a NULL SettableMetadata, mime type is NOT correctly inferred from file extension in storage firebase console and defaults to application/octet-stream
If you provide any customMetadata to SettableMetadata (for example customMetadata: {'picked-file-path': file.path}) WITHOUT providing a contentType, mime type is also not inferred from file extension in firebase console
In all cases, if you do not provide a contentType to SettableMetadata, mime type is never inferred always defaults to application/octet-stream
Reproducing the issue
Use the firebase_storage package example https://pub.dev/packages/firebase_storage/example, with the following update : final metadata = SettableMetadata( contentType: 'image/jpeg', <<< COMMENT THIS LINE customMetadata: {'picked-file-path': file.path}, );
Firebase Core version
4.0.0
Flutter Version
3.35.1
Relevant Log Output
Flutter dependencies
Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.
Additional context and comments
No response