Skip to content
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

S3 folder not created when specified in the Key #389

Closed
aweick opened this issue Sep 22, 2015 · 7 comments
Closed

S3 folder not created when specified in the Key #389

aweick opened this issue Sep 22, 2015 · 7 comments
Labels
guidance Question that needs advice or information.

Comments

@aweick
Copy link

aweick commented Sep 22, 2015

When I follow the sample on the wiki to upload a folder and change the prefix variable to "hello" for example, the "hello" folder is not created in my bucket. On S3, I see a file called "hello\hello.txt" NOT a folder called "hello" with a "hello.txt" file inside of the folder.

result, err := uploader.Upload(&s3manager.UploadInput{
            Bucket: &bucket,
            Key:    aws.String(filepath.Join("hello", rel)),
            Body:   file,
        })
@reedobrien
Copy link

Are you on windows?

@aweick
Copy link
Author

aweick commented Sep 22, 2015

Sorry, yes this is occurring on Windows.

@reedobrien
Copy link

I would make that guess because a windows file path separator would be "" which doesn't appear as a "folder" in s3. In fact there are no "folders" in s3, but AWS console makes paths with "/" appear hierarchical. Try joining with "/". I.e. 'path.Join'. I don't have windows so I don't know if that will use "" or "/".

@aweick
Copy link
Author

aweick commented Sep 22, 2015

That did it, thanks! I am going to have to code around this depending on the OS. Seems like this should be handled by the UploadManager or am I mistaken and this is as designed?

@reedobrien
Copy link

I don't know about "design" intentions. Probably more like cognitive impedance. There is no hierarchy in s3. Each object has a key, this/is/not/a/path/but/a/key.txt could just as easily be this\is\not\a\path\but\a\key.txt, however those are two different keys representing two different objects.
Things can share a prefix... but there is no hierarchy. The s3 console does a bit of a disservice to users making it appear as a file system hierarchy, but I suppose that lowers the cognitive load for new users.

@jasdel jasdel added the guidance Question that needs advice or information. label Sep 22, 2015
@jasdel
Copy link
Contributor

jasdel commented Sep 22, 2015

Hi @aweick, it looks like the issue you were having is resolved. Like @reedobrien mentioned S3 does not actually store objects in a file hierarchy, but by a key. Tools such as the AWS S3 Console will display content as a file hierarchy by interpreting the \ as directory separators to make it easier to view buckets with a lot prefixed of content.

If you're looking to maintain this functionality I agree using path.Join() is a good way to join these components. path.Join is OS/Platform augnostic using \ as path component seperator.

@aweick
Copy link
Author

aweick commented Sep 22, 2015

Hi @jasdel. I understood that S3 does not really have folders. The mistake I made was thinking that the SDK would handle the slashes appropriately for S3. As the example code on the wiki yields different results depending on the platform I would recommend that it get updated to something agnostic as well.

@aweick aweick closed this as completed Sep 22, 2015
skotambkar added a commit to skotambkar/aws-sdk-go that referenced this issue May 20, 2021
Services
---
* Synced the V2 SDK with latest AWS service API definitions.

SDK Enhancements
---
* `aws/endpoints`: Expose DNSSuffix for partitions ([aws#369](aws/aws-sdk-go-v2#369))
  * Exposes the underlying partition metadata's DNSSuffix value via the `DNSSuffix` method on the endpoint's `Partition` type. This allows access to the partition's DNS suffix, e.g. "amazon.com".
  * Fixes [aws#347](aws/aws-sdk-go-v2#347)
* `private/protocol`: Add support for parsing fractional timestamp ([aws#367](aws/aws-sdk-go-v2#367))
  * Fixes the SDK's ability to parse fractional unix timestamp values and adds tests.
  * Fixes [aws#365](aws/aws-sdk-go-v2#365)
* `aws/ec2metadata`: Add marketplaceProductCodes to EC2 Instance Identity Document ([aws#374](aws/aws-sdk-go-v2#374))
  * Adds `MarketplaceProductCodes` to the EC2 Instance Metadata's Identity Document. The ec2metadata client will now retrieve these values if they are available.
  * Related to: [aws#2781](aws#2781)
* `aws`: Adds configurations to the default retryer ([aws#375](aws/aws-sdk-go-v2#375))
  * Provides more customization options for retryer by adding a constructor for default Retryer which accepts functional options. Adds NoOpRetryer to support no retry behavior. Exposes members of default retryer.
  * Updates the underlying logic used by the default retryer to calculate jittered delay for retry. Handles int overflow for retry delay.
  * Fixes [aws#370](aws/aws-sdk-go-v2#370)
* `aws` : Refactors request retry behavior path logic ([aws#384](aws/aws-sdk-go-v2#384))
  * Retry utilities now follow a consistent code path. aws.IsErrorRetryable is the primary entry point to determine if a request is retryable.
  * Corrects sdk's behavior by not retrying errors with status code 501. Adds support for retrying the Kinesis API error, LimitExceededException.
  * Fixes [aws#372](aws/aws-sdk-go-v2#372), [aws#145](aws/aws-sdk-go-v2#145)

SDK Bugs
---
* `aws`: Fixes bug in calculating throttled retry delay ([aws#373](aws/aws-sdk-go-v2#373))
  * The `Retry-After` duration specified in the request is now added to the Retry delay for throttled exception. Adds test for retry delays for throttled exceptions. Fixes bug where the throttled retry's math was off.
  * Fixes [aws#45](aws/aws-sdk-go-v2#45)
* `aws` : Adds missing sdk error checking when seeking readers ([aws#379](aws/aws-sdk-go-v2#379))
  * Adds support for nonseekable io.Reader. Adds support for streamed payloads for unsigned body request.
  * Fixes [aws#371](aws/aws-sdk-go-v2#371)
* `service/s3` : Fixes unexpected EOF error by s3manager ([aws#386](aws/aws-sdk-go-v2#386))
  * Fixes bug which threw unexpected EOF error when s3 upload is performed for a file of maximum allowed size
  * Fixes [aws#316](aws/aws-sdk-go-v2#316)
* `private/model` : Fixes generated API Reference docs links being invalid ([387](aws/aws-sdk-go-v2#387))
  * Fixes [aws#327](aws/aws-sdk-go-v2#327)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

3 participants