title: Using boto3, how to put a publicly-readable object into S3 (or DigitalOcean Spaces)
body: <p>Can someone provide a complete example of the following: Use boto3 and Python (2.7) to upload a file from a desktop computer to DigitalOcean Spaces, such that the uploaded file would be publically readable from Spaces.  </p>
  
  <p>DigitalOcean says their Spaces API is the same as the S3 API.  I don't know if this is 100% true, but here is their API: <a href="https://developers.digitalocean.com/documentation/spaces" rel="nofollow noreferrer">https://developers.digitalocean.com/documentation/spaces</a></p>
  
  <p>I can do the file-upload, with the code below, but I can't find an example of how to specify the file be publically readable.  I do not want to make the entire Space (= S3 bucket) readable -- only the object.</p>
  
  <pre><code>import boto3
  boto_session = boto3.session.Session()
  boto_client = boto_session.client('s3',
                      region_name='nyc3',
                      endpoint_url='https://nyc3.digitaloceanspaces.com',
                      aws_access_key_id='MY_SECRET_ACCESS_KEY_ID',
                      aws_secret_access_key='MY_SECRET_ACCESS_KEY')
  boto_client.upload_file( FILE_PATHNAME, BUCKETNAME, OBJECT_KEYNAME )
  </code></pre>
  
  <p>Changing the last statement to the following did not work:</p>
  
  <pre><code>boto_client.upload_file( FILE_PATHNAME, BUCKETNAME, OBJECT_KEYNAME, 
                           ExtraArgs={ 'x-amz-acl': 'public-read', } )
  </code></pre>
  
  <p>Thank you.</p>