Giter Club home page Giter Club logo

Comments (3)

JesseLovelace avatar JesseLovelace commented on July 28, 2024

Updating user provided blob metadata is possible with the Java client, it's just not necessarily intuitive. You have to unset the metadata first and then update it with a complete map. How to do so is documented here. With this you could simulate updating a single field by loading the map returned by blob.getMetadata() into a copy, editing the value you want to update in the copy, and then using blob.update() after nulling the original map to set the new metadata map to the copy.

We can look into adding a method for specifically updating one field, but I hope this unblocks you in the meantime.

from java-storage.

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

Updating user provided blob metadata is possible in the same way as updating other Blob information Storage.update() method.
The code below demonstrates how to do this:

        Map<String, String> init = new HashMap<>();
        init.put("a", "b");
        init.put("c", "d");
        BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setMetadata(init).build();
        Blob blob = storage.create(blobInfo);
        System.out.println("initial: " + blob.getMetadata());


        Map<String, String> update = new HashMap<>();
        update.put("x", "y");
        update.put("c", null);
        BlobInfo blobUpdate = BlobInfo.newBuilder(blobId).setMetadata(update).build();
        blob = storage.update(blobUpdate);
        System.out.println("updated: " + blob.getMetadata());

The output:

initial: {a=b, c=d}
updated: {x=y, a=b}

from java-storage.

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

@JesseLovelace, @jkubrynski
Can we close this issue?

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.