You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Feature suggestion: auto content-type on blob creation #47
What if the API saves the blob setting it's content-type automatically? I guess it would make sense at least for public blobs. Do you have an opinion on that?
I assume you mean that we would try to detect the file type and automatically set the Content-type metadata for the blob.
On the client side, we don't do this for developers because there are several different ways to accomplish in Java (extension, magic bytes) this with pros/cons for each method. We don't want to dictate how or whether to automatically detect the mime type so it's left to developers to do. You can do a quick Google search for "java file mime type" for several methods of detecting the mime type.
@chingor13 thoughts on providing a setContentTypeMapping(Map<String, String> map) on StorageOptions.Builder to setup an blob name extension to content-type mapping?
It would be completely optional and shouldn't breaking any existing code.
Activity
chingor13 commentedon Dec 7, 2018
I assume you mean that we would try to detect the file type and automatically set the Content-type metadata for the blob.
On the client side, we don't do this for developers because there are several different ways to accomplish in Java (extension, magic bytes) this with pros/cons for each method. We don't want to dictate how or whether to automatically detect the mime type so it's left to developers to do. You can do a quick Google search for "java file mime type" for several methods of detecting the mime type.
If you'd like to file a feature request against the actual backend API, you can file an issue against the service: https://issuetracker.google.com/issues/new?component=187243&template=0
andrey-qlogic commentedon Jan 18, 2019
@chingor13 , is there any update on this feature request?
dhoard commentedon Mar 12, 2019
@chingor13 thoughts on providing a
setContentTypeMapping(Map<String, String> map)onStorageOptions.Builderto setup an blob name extension to content-type mapping?It would be completely optional and shouldn't breaking any existing code.
andrey-qlogic commentedon Mar 14, 2019
@chingor13 , @dhoard
I would assume that we can add something like the example below
similar to https://github.com/googleapis/google-cloud-java/blob/35cc9874ce2963ca9d66aa0d584208a59154b6f3/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java#L611
dhoard commentedon Mar 14, 2019
@andrey-qlogic conceptually that might work. From an implementation standpoint, it would be better to perform a
get()on theheaderProvider...@chingor13 your feedback?
dmitry-fa commentedon May 20, 2020
Similar fix in nodejs: googleapis/nodejs-storage#1190