Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Creating a key prefix also creates an object with the same name #151

Open
deviantintegral opened this issue Jul 13, 2016 · 3 comments
Open

Comments

@deviantintegral
Copy link

If you create a key prefix, such as 'my-folder/', and then check to see if the key 'my-folder' exists, fakes3 returns an object for the key instead of a 404. This breaks clients that are doing directory operations, as if they create a directory, but then checks to see if the key is a file or a directory, the client sees a file.

@tobeycodes
Copy link

@deviantintegral do you have a fix for this?

@radeksimko
Copy link

Here's a repro case to demonstrate the difference between real S3 API and Fake S3:

Empty file:

$ touch empty.txt
$ du empty.txt
0   empty.txt

Real S3

aws s3api put-object --bucket=mybucket --key=first/second/third/ --body empty.txt
{
    "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\""
}

Without trailing slash

aws s3api head-object --bucket=mybucket --key=first/second/third

An error occurred (404) when calling the HeadObject operation: Not Found

With trailing slash

aws --profile=ti-devops-test s3api head-object --bucket=rsimkotest --key=first/second/third/
{
    "AcceptRanges": "bytes",
    "ContentType": "binary/octet-stream",
    "LastModified": "Mon, 07 Nov 2016 14:11:53 GMT",
    "ContentLength": 0,
    "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"",
    "Metadata": {}
}

Fake S3

aws --endpoint-url=http://localhost:64569 s3api put-object --bucket=mybucket --key=first/second/third/ --body empty.txt
{
    "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\""
}

Without trailing slash

aws --endpoint-url=http://localhost:64569 s3api head-object --bucket=mybucket --key=first/second/third
{
    "AcceptRanges": "bytes",
    "ContentType": "",
    "LastModified": "Mon, 07 Nov 2016 14:13:53 GMT",
    "ContentLength": 0,
    "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"",
    "Metadata": {}
}

With trailing slash

aws --endpoint-url=http://localhost:64569 s3api head-object --bucket=mybucket --key=first/second/third/
{
    "AcceptRanges": "bytes",
    "ContentType": "",
    "LastModified": "Mon, 07 Nov 2016 14:13:53 GMT",
    "ContentLength": 0,
    "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"",
    "Metadata": {}
}

@deviantintegral
Copy link
Author

No, we ended up using the ceph docker container instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants