Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I check if an object exists #28

Open
bpmason1 opened this issue Feb 28, 2019 · 1 comment
Open

How do I check if an object exists #28

bpmason1 opened this issue Feb 28, 2019 · 1 comment

Comments

@bpmason1
Copy link

After perusing the source code I'm wondering if there is an easier way to check if a file exists? Obviously, I could try to fetch the file and see if anything returns but this is an expensive operation. It would be nice if there was a function to wrap a basic HEAD request to check for the existence of a file.

@kothar
Copy link
Owner

kothar commented Apr 29, 2019

Hi @bpmason1, sorry for the excessive delay in replying, I've not been paying enough attention to the issues emails :/

This seems like a good feature suggestion, and should be straight forward to implement.
A similar issue for the official Java SDK was resolved using a HEAD request: Backblaze/b2-sdk-java#28

As a workaround in the meantime, I would suggest GetFileInfo as an alternative to downloading the file content. Both of these are class B transactions. There's no information on whether a HEAD request would is charged differently than a GetFileInfo request.

When only the header information is required, the HEAD request provides a more efficient means of retrieving the headers than requesting the first few bytes of the file.

However, the download API HEAD method has the advantage that it has optional auth, so would allow existence checks for public objects without an authorization token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants