I’m trying to upload a file accoring to these instructions: https://www.digitalocean.com/community/questions/how-to-upload-an-object-to-digital-ocean-spaces-using-python-boto3-library
This is my code:
#!/bin/env python3 import boto3 boto3.set_stream_logger('') key = 'KEY' secret = 'SECRET' space_name = 'my-space-name' filename = 'test.7z' session = boto3.session.Session() client = session.client('s3', region_name='ams3', endpoint_url='https://ams3.digitaloceanspaces.com', aws_access_key_id=key, aws_secret_access_key=secret) client.upload_file(filename, # Path to local file space_name, # Name of Space filename) # Name for remote file
However, the script never terminates and the upload fails. This is a part of the debug output:
PUT /MYFILENAME content-md5:7eHKybMEoOqUlWWM5c+5Qg== host:ams3.digitaloceanspaces.com x-amz-content-sha256:UNSIGNED-PAYLOAD x-amz-date:20180104T224246Z content-md5;host;x-amz-content-sha256;x-amz-date UNSIGNED-PAYLOAD 2018-01-04 23:42:46,436 botocore.auth [DEBUG] StringToSign: AWS4-HMAC-SHA256 20180104T224246Z 20180104/us-east-1/s3/aws4_request 63867e94f9f05f2dcbcad9a3c71c57b29b31f3fca17160ccce9214c174eac402 2018-01-04 23:42:46,436 botocore.auth [DEBUG] Signature: a577db0b4b5d6127cb787be070b26ed368fff7e7c0883588f771cb5ca26d3f19 2018-01-04 23:42:46,436 botocore.hooks [DEBUG] Event request-created.s3.PutObject: calling handler <function signal_transferring at 0x7f6df549a268> 2018-01-04 23:42:46,437 botocore.endpoint [DEBUG] Sending http request: <PreparedRequest [PUT]> 2018-01-04 23:42:46,438 botocore.vendored.requests.packages.urllib3.connectionpool [INFO] Starting new HTTPS connection (3): ams3.digitaloceanspaces.com 2018-01-04 23:42:46,602 botocore.awsrequest [DEBUG] Waiting for 100 Continue response. 2018-01-04 23:42:46,633 botocore.awsrequest [DEBUG] 100 Continue response seen, now sending request body.
Eventually the connection times out and a new attempt will be made.
I can upload a very small file containing only test123. However, also there the scipt does not terminate as well. But the file will be visible in the space. The file I’m actually trying to upload is about 300kb.
I would greatly appreciate any help you might be able to give. Thank you very much!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Click below to sign up and get $200 of credit to try our products over 60 days!