Skip to content

No easy way to copy a single directory to s3 #2069

Open
@xiongchiamiov

Description

@xiongchiamiov

My apologies if this has been discussed before; I tried my best to search for it (difficult) and read through the relevant labels.

Given a directory with multiple things in it:

/tmp
├── aaa
    ├── foo
    ├── bar
├── bbb
├── ccc

I'd like to copy one of those directories to s3, the equivalent of cp -r /tmp/aaa /my-bucket/.

Unfortunately, both aws s3 cp and aws s3 sync act more like cp -r /tmp/aaa/* /my-bucket/ - that is, they skip the containing directory and splat all its containing files directly into the root of the bucket. Running either

[$]> aws s3 sync /tmp/aaa s3://my-bucket

or

[$]> aws s3 cp /tmp/aaa s3://my-bucket --recursive

will result in the contents of aaa residing in s3:

my-bucket:
├── foo
├── bar

(For my particular purposes, I don't care about synchronization, but was just hoping that perhaps sync would act as I hoped. Existing documentation aside, I would expect aws s3 cp to act like cp and aws s3 sync to act like rsync, in regards to directories, at least as far as can happen with s3's lack of actual directories.)

This is annoying, because it forces me to basename the directory and tack that on to the end of the bucket. It's also surprising; not only does it not act like common *nix utilities, but aws s3 sync help implies a different behavior via its use of . as a source directory for all examples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeIssue requires a breaking change to remediate.feature-requestA feature should be added or improved.needs-major-versionCan only be considered for the next major releasep3This is a minor priority issues3

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions