def upload_file_to_bucket(self, bucket, file_path, key, is_public=False):
        """ Upload files to S3 Bucket """

        with open(file_path, 'rb') as data:
            self.__s3.upload_fileobj(data, bucket, key)

        if is_public:
            self.__s3.put_object_acl(ACL='public-read', Bucket=bucket, Key=key)

        bucket_location = self.__s3.get_bucket_location(Bucket=bucket)
        file_url = "https://s3-{0}.amazonaws.com/{1}/{2}".format(
            bucket_location['LocationConstraint'],
            bucket,
            key)

        return file_url
def upload_file_to_bucket ( self , bucket , file_path , key , is_public = False ) : with open ( file_path , 'rb' ) as data : self . __s3 . upload_fileobj ( data , bucket , key ) if is_public : self . __s3 . put_object_acl ( ACL = 'public-read' , Bucket = bucket , Key = key ) bucket_location = self . __s3 . get_bucket_location ( Bucket = bucket ) file_url = "https://s3-{0}.amazonaws.com/{1}/{2}" . format ( bucket_location [ 'LocationConstraint' ] , bucket , key ) return file_url
Upload files to S3 Bucket