-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Description
Hello, I'm using such hack to check if file exist on bucket or not.
public boolean isBlobExist(String bucket, String uid) throws Exception {
/**
* b2_download_file_by_name $0.004 per 10,000 cheaper 10x times
* b2_list_file_names $0.004 per 1,000
*/
try {
B2DownloadByNameRequest downloadRequest = B2DownloadByNameRequest.builder(bucket, uid)
.setRange(B2ByteRange.between(0, 1)).build();
EmptyBlobSink sink = new EmptyBlobSink();
client.downloadByName(downloadRequest, sink);
long length = sink.getResponseHeaders().getContentLength();
return length > 0;
} catch (B2Exception e) {
if (e.getStatus() == 404 && e.getMessage().contains("does not have file"))
return false;
else throw e;
}
}
Is it possible to execute such request as a HEAD?
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels