Skip to content

Instantly share code, notes, and snippets.

@philographer
Last active April 18, 2017 00:57
Show Gist options
  • Save philographer/ef2e8b610f7c9eb2a573c7069e0e46bd to your computer and use it in GitHub Desktop.
Save philographer/ef2e8b610f7c9eb2a573c7069e0e46bd to your computer and use it in GitHub Desktop.
Python S3 Upload by Boto

Python S3 Upload by Boto

client = boto3.client('s3')
        bucket_name = 'api_reports'

        resp = client.put_object(
                                Bucket= bucket_name, 
                                Key= filename, 
                                Body= file,
                                Expires= datetime.utcnow() + timedelta(days=7), )
        print(resp)
        url = client.generate_presigned_url(
                                            'get_object', 
                                            Params = { 
                                                      'Bucket': bucket_name, 
                                                      'Key': filename, }, 
                                            ExpiresIn = 86400, )
        print(url)
@philographer
Copy link
Author

보안 설정
~/.boto
[s3] use-sigv4 = True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment