phpfilefile-uploadamazon-s3amazon-web-services

Amazon S3 avoid overwriting objects with the same name


If I upload a file to S3 with the filename identical to a filename of an object in the bucket it overwrites it. What options exists to avoid overwriting files with identical filenames? I enabled versioning in my bucket thinking it will solve the problem but objects are still overwritten.


Solution

  • My comment from above doesn't work. I thought the WRITE ACL would apply to objects as well, but it only works on buckets.

    Since you enabled versioning, your objects aren't overwritten. But if you don't specify the version in your GET request or URL, the latest version will be taken. This means when you put and object into S3 you need to save the versionID the response tells you in order to retrieve the very first object.

    See Amazon S3 ACL for read-only and write-once access for more.