Skip to content

[FIREBASE_STORAGE] Flutter WEB : mime/contentType defaults to application/octet-stream after upploading files to firebase storage if contentType is not provided in settableMetadata #17651

@pureimpro

Description

@pureimpro

Is there an existing issue for this?

  • 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 #12363 and #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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs AttentionThis issue needs maintainer attention.platform: webIssues / PRs which are specifically for web.plugin: storagetype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions