Update existing files
As S3 objects are immutable the update operation of an already uploaded file is not possible (only file's metadata can be updated) in a traditional way. However, we could create an method where we make use of putObject
method of aws-sdk
. This method will override an existing file with the one provided as argument to that method, or will create a new file from scratch if the provided objectKey
is not already present in the defined bucket
for the file server.
Relevant documentation can be found https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html.
We should be very cautious to not bypass our existing flow of automatically creating multiple versions of image files via allowing uploading new files with putObject
instead of our official upload
method.