You are trying to copy files from a location to an s3 bucket.
Let’s assume that the name of the directory you are attempting to copy files from is named
dist (short for distribution).
When using the AWS CLI to copy new files to an S3 bucket using the command
aws s3 cp ./dist s3://<<bucket name>>, the command fails with this error:
Invalid length for parameter Key, value: 0, valid range: 1-inf
This error is caused when you don’t specify the name of the files that you want to copy.
By default the
cp command in the cli doesn’t recursively search for files and directories that you are trying to copy.
Since you haven’t specified which files that you want to copy to the s3 bucket, you will get the above error.
So you have to specify the exact file that you want copy e.g.
aws s3 cp ./dist/my-file-name.pdf s3://<<bucket name>>
Alternatively if you want to copy everything in the
dist directory to the s3 bucket, you need to use the
--recursive flag and don’t need to specify file names.
aws s3 cp ./dist s3://<<bucket name>> --recursive
This flag will instruct the cli to copy all files and directories in
dist to the s3 bucket.