Skip to content
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

[storage] Incorrect mime type inferred when not manually setting metadata #5734

Closed
Lyokone opened this issue Feb 22, 2024 · 1 comment
Closed

Comments

@Lyokone
Copy link

Lyokone commented Feb 22, 2024

This issue is related to another issue reported to firebase/flutterfire#12363
The issue does not appear when running the same logic on iOS.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: 2022.3.1
  • Firebase Component: Storage
  • Component version: BoM 32.7.2

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

When uploading a file without any metadata, the metadata are not inferred properly. For instance uploading a jpeg file to the Firebase emulator will give a mime type of "application/octet-stream" instead of "image/jpeg".

Relevant Code:

reference.putFile("file:///data/user/0/io.flutter.plugins.firebasestorageexample/cache/54cd5d7d-1718-4353-a4ce-a87c8c29b28d/dog-puppy-on-garden-royalty-free-image-1586966191.jpg")
@lehcar09
Copy link

Hi @Lyokone, thank you for reaching out. I tried reproducing the issue with the quickstart app, but I did not encounter the issue. I tried photoRef.putFile(fileUri) and photoRef.putFile(fileUri, storageMetadata {}) and the contentType is still intact upon upload.

Just to note, according to our documentation,

The putFile() method automatically infers the MIME type from the File extension, but you can override the auto-detected type by specifying contentType in the metadata. If you do not provide a contentType and Cloud Storage cannot infer a default from the file extension, Cloud Storage uses application/octet-stream.See the Use File Metadata section for more information about file metadata.

I suggest try running our quickstart app to help troubleshoot the issue. Let me know if I misunderstood anything.

@firebase firebase locked and limited conversation to collaborators Mar 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants