Comments (3)
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.
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.
@JesseLovelace, @jkubrynski
Can we close this issue?
from java-storage.
Related Issues (20)
- 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
- com.example.storage.bucket.PrintPubSubNotificationTest: testPrintBucketPubSubNotification failed HOT 2
- Warning: a recent release failed HOT 2
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.