Open sqs opened 9 years ago
Okay, I've been looking into this a lot and I see three potential solutions to this:
1 and 2 below both rely on the idea that we can identify at Close
time that no parts have been uploaded (which should be trivial).
p.len == 0
) part into the stream using uploader.putPart
in hopes that S3 will take that without error.uploader.abort
and then upload a zero-byte object using PUT
directly (see here).Write
and if we reach Close
without any previous calls to Write
, upload a zero-byte object using PUT
directly (see here)
I'll see if I can't get access to an S3 account sometime soon to test these potential solutions and make a small example to reproduce the issue.
I implemented @slimsag's fix 2 pretty roughly, but it seems to be working. Check https://github.com/sqs/s3/commit/49acf3c4a7a4b5fe2dd24f636de56c7497430b30.
If you call Create and then immediately Close the file without writing anything (e.g., for an empty file), the upload fails and no file is created. This is because the Close method sends a CompleteMultipartUpload tag with no children:
The AWS API docs at http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadComplete.html say that the CompleteMultipartUpload element requires one or more Parts.