-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PutObject creates empty file when using the JS AWS SDK #121
Comments
This appears to be a bug when using the aws cli as well:
I tried setting the content-type, content-length, and content-encoding to no avail. I also tried the docker image versions 2.1.0, 2.0.0, 1.1.0, and 1.0.0. Earlier versions throw an error about not being able to write a file, but newer versions just save a 0 byte file. |
I have the same issue when uploading using boto3 (Python AWS client). |
I seem to be getting the same issue when using the ruby gem sdk using the below code:
If I upload using java sdk using the following code it works:
Any ideas? |
I have the same issue using python's In [56]: c.put_object(Key='mykey', Bucket='mybucket', Body=json.dumps({'a':1}) )
Out[56]:
{'ResponseMetadata': {'HTTPStatusCode': 200,
'HTTPHeaders': {'date': 'Tue, 30 Apr 2019 21:58:56 GMT',
'last-modified': 'Tue, 30 Apr 2019 21:58:56 GMT',
'etag': '"d41d8cd98f00b204e9800998ecf8427e"',
'content-length': '0',
'server': 'Jetty(9.4.14.v20181114)'},
'RetryAttempts': 0},
'ETag': '"d41d8cd98f00b204e9800998ecf8427e"'}
In [57]: c.get_object(Key='mykey', Bucket='mybucket')['Body'].read()
Out[57]: b''
|
I was able to get to work by using signatureVersion v3 |
Having the same issue using the golang client |
@davidsbond I was running into the same issue with boto3. As @haarcuba mentioned, this can be resolved by setting the signature version like so: boto3client(
"s3",
endpoint_url="http://yours3mock",
config=boto3.session.Config(signature_version="v3"),
) This only needs to be done for the resource/client that is doing the uploading. Once uploaded properly, the files seem accessible through other operations (list_objects, get... etc) |
Thanks @nealstewart, I'm unable to find a way of setting the signature version using the aws golang client. I can't seem to find an option for it in the configuration, although it could be named something else. For now I was able to directly mock the S3 bucket locally using another library. |
I needed some help with getting a reproducer to work and debug, and after that it turned out that boto3 and the golang client (apparently) used a combination of v4 signing and non-chunked transfer that resulted in the problem. The S3Mock didn't expect v4 signing without chunking 🤷♂. The fix is on its way... |
@BLevinger saved my day! Thanks. |
This creates an empty file at
/root/my-bucket/some-key/fileData
:We've tried different body types, as well as specifying
ContentType
andContentLength
, with the same results.It seems related to
ContentLength
as when uploading a file usingcurl
, the file is empty when aContent-Length
header is not provided.The text was updated successfully, but these errors were encountered: