okigan / awscurl

curl-like access to AWS resources with AWS Signature Version 4 request signing.
MIT License
737 stars 91 forks source link

Support for binary files #90

Closed sp-davidpichler closed 4 months ago

sp-davidpichler commented 3 years ago

I wasn't able to send a binary file without the above changes Stacktrace:

Traceback (most recent call last):
  File "/Users/dpichler/anaconda2/envs/voice-cloning-updated/bin/awscurl", line 8, in <module>
    sys.exit(main())
  File "/Users/dpichler/anaconda2/envs/voice-cloning-updated/lib/python3.6/site-packages/awscurl/awscurl.py", line 501, in main
    inner_main(sys.argv[1:])
  File "/Users/dpichler/anaconda2/envs/voice-cloning-updated/lib/python3.6/site-packages/awscurl/awscurl.py", line 454, in inner_main
    data = post_data_file.read()
  File "/Users/dpichler/anaconda2/envs/voice-cloning-updated/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 4: invalid start byte
sp-davidpichler commented 3 years ago

Let me know if I'm doing something stupid. How else would you send binary data if not through a file?

okigan commented 3 years ago

@sp-davidpichler the change looks plausible

what's the content of you file? is the file itself correct? (or how do you know it's correct?)

sp-davidpichler commented 3 years ago

I don't know if it works yet. I'm trying to send an audio file(.wav) but haven't gotten this to work. I haven't got my backend application to successfully load the audio file. I think the contents are getting altered somehow. Or there is some other error.

Locally I can load the file in 'rb' mode and process it.

sp-davidpichler commented 3 years ago

I ended up just using S3 and passing the path to the object.

chenliu0831 commented 4 months ago

Could we merge this? I run into the same issue when POST binary data with --data-binary and POST -d "@test.binary"

chenliu0831 commented 4 months ago

@okigan any chance we could merge this as well?