aws / aws/aws-cli

PutObject does not accept base64 encoded strings

Open
#5,465 8 comments 3 reactions 0 assignees View on GitHub
documentation enhancement feature-request p2 s3api
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

Confirm by changing [ ] to [x] below to ensure that it's a bug:
- [x] I've gone though the [User Guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) and the [API reference](https://docs.aws.amazon.com/cli/latest/reference/)
- [x] I've searched for [previous similar issues](https://github.com/aws/aws-cli/issues) and didn't find any solution

**Describe the bug**

According to the documentation, a parameter with type `blob` can either be a reference to a file or a base64-encoded string. However, when passing in a base64-encoded string for the `body` parameter, the AWS CLI returns the following error:

```
Error parsing parameter '--body': Blob values must be a path to a file.
```

The docs I'm referencing are here: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-parameters-types.html#parameter-type-blob

**SDK version number**
aws-cli/2.0.7 Python/3.7.4 Darwin/18.7.0 botocore/2.0.0dev11

**Platform/OS/Hardware/Device**
macOS Mojave 10.14.6

**To Reproduce (observed behavior)**

Command for `aws` cli:

```bash
aws s3api put-object --key simple-key-value.json --body "eyJ0ZXN0IjoidmFsdWUifQ==" --bucket [bucket]
```

Replace [bucket] with any bucket you have access to.

**Expected behavior**
The CLI writes the string to S3 without errors.

**Logs/output**
```
$ aws s3api put-object --cli-binary-format base64 --key simple-key-value.json --body 'eyJ0ZXN0IjoidmFsdWUifQ==' --bucket snaps-development-dumps --debug
2020-08-10 17:24:50,575 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.0.7 Python/3.7.4 Darwin/18.7.0 botocore/2.0.0dev11
2020-08-10 17:24:50,575 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['s3api', 'put-object', '--cli-binary-format', 'base64', '--key', 'simple-key-value.json', '--body', 'eyJ0ZXN0IjoidmFsdWUifQ==', '--bucket', 'snaps-development-dumps', '--debug']
2020-08-10 17:24:50,575 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler
2020-08-10 17:24:50,575 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler
2020-08-10 17:24:50,576 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler
2020-08-10 17:24:50,576 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler
2020-08-10 17:24:50,583 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler
2020-08-10 17:24:50,583 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler
2020-08-10 17:24:50,593 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/botocore/data/s3/2006-03-01/service-2.json
2020-08-10 17:24:50,604 - MainThread - botocore.hooks - DEBUG - Event building-command-table.s3api: calling handler
2020-08-10 17:24:50,612 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/botocore/data/s3/2006-03-01/waiters-2.json
2020-08-10 17:24:50,614 - MainThread - awscli.clidriver - DEBUG - OrderedDict([('acl', ), ('body', ), ('bucket', ), ('cache-control', ), ('content-disposition', ), ('content-encoding', ), ('content-language', ), ('content-length', ), ('content-md5', ), ('content-type', ), ('expires', ), ('grant-full-control', ), ('grant-read', ), ('grant-read-acp', ), ('grant-write-acp', ), ('key', ), ('metadata', ), ('server-side-encryption', ), ('storage-class', ), ('website-redirect-location', ), ('sse-customer-algorithm', ), ('sse-customer-key', ), ('sse-customer-key-md5', ), ('ssekms-key-id', ), ('ssekms-encryption-context', ), ('request-payer', ), ('tagging', ), ('object-lock-mode', ), ('object-lock-retain-until-date', ), ('object-lock-legal-hold-status', )])
2020-08-10 17:24:50,614 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.s3api.put-object: calling handler
2020-08-10 17:24:50,614 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.s3api.put-object: calling handler
2020-08-10 17:24:50,614 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.s3api.put-object: calling handler
2020-08-10 17:24:50,614 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.s3api.put-object: calling handler
2020-08-10 17:24:50,622 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/botocore/data/s3/2006-03-01/paginators-1.json
2020-08-10 17:24:50,622 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.s3api.put-object: calling handler
2020-08-10 17:24:50,622 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.s3api.put-object: calling handler
2020-08-10 17:24:50,622 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.s3api.put-object: calling handler >
2020-08-10 17:24:50,622 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.s3api.put-object: calling handler >
2020-08-10 17:24:50,622 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.s3api.put-object: calling handler >
2020-08-10 17:24:50,622 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.s3api.put-object: calling handler >
2020-08-10 17:24:50,624 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.s3.put-object.acl: calling handler
2020-08-10 17:24:50,624 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.s3.put-object.body: calling handler
2020-08-10 17:24:50,624 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.s3.put-object: calling handler
2020-08-10 17:24:50,624 - MainThread - awscli.clidriver - DEBUG - Client side parameter validation failed
Traceback (most recent call last):
File "awscli/clidriver.py", line 335, in main
File "awscli/clidriver.py", line 507, in __call__
File "awscli/clidriver.py", line 656, in __call__
File "awscli/clidriver.py", line 712, in _build_call_parameters
File "awscli/arguments.py", line 453, in add_to_params
File "awscli/arguments.py", line 470, in _unpack_argument
File "awscli/argprocess.py", line 143, in unpack_cli_arg
File "awscli/argprocess.py", line 160, in _unpack_cli_arg
File "awscli/argprocess.py", line 227, in unpack_scalar_cli_arg
awscli.argprocess.ParamError: Error parsing parameter '--body': Blob values must be a path to a file.

Error parsing parameter '--body': Blob values must be a path to a file.
```

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.