(R2) Overwriting files
Say I want to overwrite a file. Do I need to delete it, then reupload? Or is reuploading alone sufficient?
What if the file is large and is being transferred via multipart? How do I overwrite that kind of file.
4 Replies
You don't need to delete, just reupload.
If its multipart then the old file will only be replaced when you complete the multipart upload.
ahh thanks that is just perfect 🙂 Is there any documention of this behavior? In other words, is this something I can absolutely rely on? as otherwise it might break my program which deals with backup data.
Thanks for the answer btw @Erisa
R2 implements an S3-compatible API and that behaviour comes from the way S3-compatible object storages work.
Amazon are quite cagey about this and many of their docs mention versioning which R2 doesnt implement, the closest I can find is https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
Amazon S3 is a distributed system. If it receives multiple write requests for the same object simultaneously, it overwrites all but the last object written.Not sure why they specify "simultaneously"
hmm thanks. Overwriting seems to be the intended behavior for PutObject, but I can't really find any evidence for multiparts