Created
September 26, 2017 09:54
-
-
Save arshpreetsingh/e2538fdddee8a5ee4858ffdcdec34560 to your computer and use it in GitHub Desktop.
amazon_uploader using boto3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
import boto3 | |
class AmazonTask(object): | |
def __init__(self,amazon_key,secret_key,bucket_name): | |
self.amazon_key=amazon_key | |
self.bucket_name=bucket_name | |
self.aws_secret=secret_key | |
self.conx = boto3.resource('s3', aws_access_key_id=self.amazon_key,aws_secret_access_key=self.aws_secret) | |
def upload_image(self,file_name,file_key): | |
uploader = self.conx.meta.client.upload_file(file_name,self.bucket_name,file_key) | |
return uploader | |
amazon_key = '' | |
secret_key = '' | |
bucket_name = '' | |
a = AmazonTask(amazon_key,secret_key,bucket_name) | |
print 'uploading' | |
a.upload_image('/home/metal-machine/Desktop/Screenshot from 2017-09-19 19-27-12.png','shava-shava.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment