Objects & listings
Use putObject with either a byte array or a file path. contentType can be null to omit that header. A file upload hashes the file before sending it; do not change the file during the upload.
storage.putObject("photos", "notes/hello.txt", bytes, "text/plain");
storage.putObject("photos", "images/cat.jpg", imagePath, "image/jpeg");
try (ObjectStorageClient.ObjectData data = storage.getObject("photos", "images/cat.jpg")) {
data.body().transferTo(output);
}
ObjectStorageClient.ObjectMetadata metadata = storage.headObject("photos", "images/cat.jpg");
storage.deleteObject("photos", "notes/hello.txt");getObject returns an open stream. Close the ObjectData result even if you do not read the whole body. headObject returns length, content type, and ETag without downloading the object. A missing content length is reported as a negative value. deleteObject deletes the current object; on a versioned backend it may create a delete marker. The client does not expose version-specific operations.
List objects
listObjects(bucket, prefix, continuationToken, maxKeys) fetches one ListObjectsV2 page. prefix and the initial token can be null; maxKeys must be 1–1000. Use the returned nextContinuationToken() until it is null.
String token = null;
do {
ObjectStorageClient.ObjectPage page = storage.listObjects("photos", "images/", token, 100);
for (ObjectStorageClient.ObjectEntry item : page.objects()) {
System.out.println(item.key() + " " + item.size());
}
token = page.nextContinuationToken();
} while (token != null);Listings are pages rather than a lazy iterator. The result holds object keys, sizes, and ETags.