I am writing a file uploader on Selectel. Simplified code looks like this:
filename = 'example_watermarked.jpg' headers['Content-Length'] = str(os.path.getsize(filename)) files = { 'file' : open(filename, 'rb') } url = auth['url'] + 'images/python_uploader/' + filename response = requests.put(url, files=files, headers=headers) It turns out the next thing - the source file is 38158 bytes. File on selector - 38317 bytes. The file, of course, does not open. Where does the "extra" 159 bytes come from? What am I doing wrong?
PS os.path.getsize(filename) returns 38158, i.e. correct size.
PPS Through Postman I tried, in the same way, I downloaded a beaten file. Only now it is 38355 bytes.
Update: The following block was added to the beginning:
--de966cbba4ab406da3dd088e63bd9c7f Content-Disposition: form-data; name="file"; filename="example_watermarked.jpg" In the end - here is this:
--de966cbba4ab406da3dd088e63bd9c7f-- The rest is binary data.