Giter Club home page Giter Club logo

Comments (6)

chingor13 avatar chingor13 commented on July 28, 2024

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.

andrey-qlogic avatar andrey-qlogic commented on July 28, 2024

@chingor13 , is there any update on this feature request?

from java-storage.

dhoard avatar dhoard commented on July 28, 2024

@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.

andrey-qlogic avatar andrey-qlogic commented on July 28, 2024

@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.

dhoard avatar dhoard commented on July 28, 2024

@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.

dmitry-fa avatar dmitry-fa commented on July 28, 2024

Similar fix in nodejs: googleapis/nodejs-storage#1190

from java-storage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.