BlobId blobId = BlobId.of(bucketName, filename);
Blob blob = storage.get(blobId);
boolean isFileDeleted = storage.delete(blobId);
Here I am getting null
for blob which has space for file name. In my bucket the structure is sample-bucket/Archive 2copy.zip
. Please note the space in the file name.
Can someone help me out?
I was using the Google Java Api - StorageExample.java and was able to delete a blob with a space in his name. They are deleting the blob by id.
private static class DeleteAction extends BlobsAction {
@Override
public void run(Storage storage, BlobId... blobIds) {
// use batch operation
List<Boolean> deleteResults = storage.delete(blobIds);
int index = 0;
for (Boolean deleted : deleteResults) {
if (deleted) {
// request order is maintained
System.out.printf("Blob %s was deleted%n", blobIds[index]);
}
index++;
}
}
}
Expected: <bucket> <path>+
target/appassembler/bin/StorageExample delete bucket-name 'test file'
Blob BlobId{bucket=bucket-name, name=test file, generation=null} was deleted
As aditya nirmala pointed out:
Changed from compile 'com.google.cloud:google-cloud-storage:1.88.0' to compile 'com.google.cloud:google-cloud-storage:1.106.0' this version changes resolved the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.