I am using PHP and I am using the S3 API to upload a file, but I wanted to make sure that this exact filename doesn’t already exist in the bucket before upload.
I have found a few examples online that use “file_get_contents” but doesn’t this mean that you would have to download the entire file first? Usually, these files are about 10 mb, so ideally, I wouldn’t really want to do this.
Is there perhaps a way to use “file_get_contents” without downloading the file?
Or better yet, perhaps I could use an API request to see if the filename exists?
It’s not important to me whether or not the content, or filesize, is the same, just the filename.
Gets whether or not the specified Amazon S3 object exists in the specified bucket.
AmazonS3
doesObjectExist