I am trying to delete many files from google cloud storage at once.
I am using the following code:
public List<Boolean> deleteObjects(List<String> fileParams) {
List<BlobId> blobs =
fileParams.stream()
.map(
file -> {
logger.info("deleteObject: {}", file);
return BlobId.of(bucketName, file);
})
.collect(Collectors.toList());
return storage.delete(blobs);
}
This call takes a very long time - I tried to delete 150k files and it took almost 1 hour.
I would like to run it as "fire and forget".
I saw in the JS example that the api is async by nature:
await storage.bucket(bucketName).file(fileName).delete();
I didn't find such example for Java, either with or without a batch.
I guess I can start a new thread and run it, but I wanted to know if the API supports something like that natively.
Is it possible to run an async command natively by the api?