Comments (6)
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
from java-storage.
@chingor13 , is there any update on this feature request?
from java-storage.
@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.
from java-storage.
@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
public final String getContentType() {
if (headerProvider != null) {
for (Map.Entry<String, String> entry : headerProvider.getHeaders().entrySet()) {
if ("content-type".equals(entry.getKey().toLowerCase())) {
return entry.getValue();
}
}
}
return null;
}
from java-storage.
@andrey-qlogic conceptually that might work. From an implementation standpoint, it would be better to perform a get()
on the headerProvider
...
public final String getContentType() {
String contentType = null;
if (headerProvider != null) {
contentType = headerProvider.get("content-type");
}
return contentType;
}
@chingor13 your feedback?
from java-storage.
Similar fix in nodejs: googleapis/nodejs-storage#1190
from java-storage.
Related Issues (20)
- Storage: com.google.storage.v2.Bucket: getAclList() and getDefaultObjectAclList() always return empty lists HOT 4
- GCS Streaming upload does not respect host in StorageOption HOT 1
- Download an object's last n bytes HOT 2
- Search: java.net.MalformedURLException when using Blob WriteChannel HOT 3
- com.example.storage.ITBucketSnippets: testChangeDefaultStorageClass failed HOT 1
- com.example.storage.ITBucketSnippets: testDisableLifecycleManagement failed HOT 1
- com.example.storage.ITBucketSnippets: testDefaultKMSKey failed HOT 1
- com.example.storage.ITBucketSnippets: testBucketRetention failed HOT 1
- Java-Storage: GCS object larger than 129 GB not downloading to local system HOT 4
- replace usages of the word Apiary with Json
- Re-enable conformance tests for resumable uploads when testbench is fixed
- Cloud strorage v2 API, writeObject missing header x-goog-request-params for client streaming call HOT 9
- Cloud storage v2 API, add support for batch operations HOT 2
- Retrying idempotent requests that return 503 backendError HOT 1
- com.google.cloud.storage.StorageException: java.lang.IllegalStateException: Connection pool shut down when trying to check if bucket exists HOT 5
- CVE-2023-33953 through io.grpc.* (1.56.1) HOT 3
- com.example.storage.QuickstartSampleIT: testQuickstartGrpc failed HOT 1
- com.example.storage.QuickstartSampleIT: testQuickstartGrpcDp failed HOT 1
- Google Cloud Storage library using deprecated javax package HOT 4
- Async / streaming support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-storage.