-
Notifications
You must be signed in to change notification settings - Fork 17
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
Check if an object exists on S3 #17
Comments
We currently do not implement Amazon S3's HeadObject. This leaves you with two options. One option is listing the bucket ( The other option is trying to retrieve the first byte of an object, e.g. try {
$dummy = $s3->getObject($bucket, $objectPath, null, 0, 1)
$fileExists = true;
} catch (Exception $e) {
$fileExists = false;
} This method isn't ideal and may outright fail if you have objects with certain storage types like Glacier. I can definitely try to implement HeadObject. |
As I don't plan to have thousands of files in a bucket folder at the same time, the By the way, I see THANK YOU! |
Yes you need to define the constant upfront. We had to that because the original land main use case of the S3 repo is its integration with our backup engine. Since it's typically installed in publicly accessible folders and the server may or may not support .htaccess / web.config access controls we have the die statement to prevent any accidental directory disclosure from error messages. I'll update the README to note that. Thank you for the heads up! |
Hi, is there a way to check if an object (file) does exist in my bucket? I see Connector::getObject but that seems to download the file while I just need something like objectExists(string $path):bool
Thanks!
The text was updated successfully, but these errors were encountered: