1

I'm trying to run this CLI command in the AWS S3 console (it contains arabic characters):

aws s3 cp 's3://freedcampfilestorage/30__Gigamax_Head_DA4/اشعار فاتورة 365-32507.jpg' 's3://freedcampfilestorage/30__Gigamax_Head_DA4/اشعار فاتورة 365-32507.jpg' --metadata-directive REPLACE
--content-disposition='inline; filename="اشعار فاتورة 365.jpg"' --profile=default >> fixer.log 2>&1

This returns:

'ascii' codec can't decode byte 0xd8 in position 47: ordinal not in range(128)

Is there something I can do to make this work with non standard ASCII characters? Can I represent non standard ascii characters numerically and still make it work?

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Tool
  • 12,126
  • 15
  • 70
  • 120
  • 2
    That's not an error from bash, it's an error from Python. Bash doesn't care about character set -- a string is a string is a string. – Charles Duffy Jul 18 '18 at 20:28
  • (...speaking of, I'm guessing the `aws` command you're running is written in Python?) – Charles Duffy Jul 18 '18 at 20:29
  • That command is actually inside a text file, which I ran with "bash command.txt". So command.txt contains the actual command. – Tool Jul 18 '18 at 20:29
  • 1
    At the risk of repeating myself -- there is no code anywhere in bash that generates an error message "ordinal not in range", nor does bash have any concept of a "codec" (yes, parts of bash are multibyte-aware, but that specific error message isn't used anywhere). That's a Python error, not a bash one. – Charles Duffy Jul 18 '18 at 20:29
  • 1
    If you run `bash -x yourscript`, to see the shell log each command as it runs it, you'll see it logging your `aws` command being run, and the error happening only *after* that command has started. – Charles Duffy Jul 18 '18 at 20:30
  • Thanks for clarifying, this probably means I'll have to resolve it with Amazon Customer Support. – Tool Jul 18 '18 at 20:32
  • 1
    I've tried to edit the title in hopes that someone familiar with the `aws` command-line tool, vs. someone familiar with bash in general, will be able to help. – Charles Duffy Jul 18 '18 at 20:36
  • This a common encoding issue in Python. Without the Python stack trace, it is unclear where exactly the AWS CLI is breaking for you. If you are using Python 2.7, you might have better luck with Python 3.6. – progfan Jul 18 '18 at 22:25
  • @progfan Thank you - I will try to run it with --debug flag. – Tool Jul 18 '18 at 22:27
  • I am working with @Tool. When we move this command to a host and cat the file `$ cat he.txt aws s3 cp 's3://freedcampfilestorage/30__Gigamax_Head_DA4/ьїьЄь╧ьїь╠ ы│ьїь╙ы┬ь╠ь╘ 365-32507.jpg' 's3://freedcampfilestorage/30__Gigamax_Head_DA4/ьїьЄь╧ьїь╠ ы│ьїь╙ы┬ь╠ь╘ 365-32507.jpg' --metadata-directive REPLACE --content-disposition='inline; filename="ьїьЄь╧ьїь╠ ы│ьїь╙ы┬ь╠ь╘ 365.jpg"' --profile=default >> fixer.log 2>&1` it looks like this. Does it already represent a problem or this is how it is suppose to be? – Igor Kryltsov Jul 19 '18 at 02:21

1 Answers1

0

The error is being generated in the --content-disposition section.

The copy statement itself works fine if that is removed.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • 1
    S3 metadata does not support utf-8, which is fine in this case, because the `Content-Disposition` header doesn't, either... but see https://stackoverflow.com/q/93551/1695906 for how to use percent-encoding here, which *should* be the workaround. – Michael - sqlbot Jul 19 '18 at 00:51