# HG changeset patch # User Gustavo Andres Morero # Date 1525811037 10800 # Tue May 08 17:23:57 2018 -0300 # Node ID 79f5fe0a496a550e81cc13c44cf1c1fa18ae7c57 # Parent 8e28084a2d636e07dbb4f695f340cee018e798a6 adding client_method param for get auth link methods. diff --git a/webutils/aws/secures3.py b/webutils/aws/secures3.py --- a/webutils/aws/secures3.py +++ b/webutils/aws/secures3.py @@ -54,8 +54,8 @@ return (bucket, filename, s.scheme) - def get_auth_link(self, bucket, filename, scheme='http', - expires=300, timestamp=None): + def get_auth_link(self, bucket, filename, scheme='http', expires=300, + timestamp=None, client_method='get_object'): ''' Return a secure S3 link with an expiration on the download. key: S3 Access Key (login) @@ -64,6 +64,7 @@ filename: file path expires: Seconds from NOW the link expires timestamp: Epoch timestamp. If present, "expires" will not be used. + client_method: The client method to generate the presigned url ''' filename = quote_plus(filename) filename = filename.replace('%2F', '/') @@ -79,13 +80,13 @@ aws_secret_access_key=self.secret_key, ) url = s3_client.generate_presigned_url( - ClientMethod='get_object', + ClientMethod=client_method, Params={'Bucket': bucket, 'Key': filename}, ExpiresIn=expires_in, ) return url - def get_easy_auth_link(self, url, expires=600): + def get_easy_auth_link(self, url, expires=600, client_method='get_object'): ''' url should be the full URL to the secure file hosted on S3. examples: http://s3.amazonaws.com/your-bucket/yourfile.zip @@ -97,4 +98,5 @@ except ValueError: return None - return self.get_auth_link(*data[:2], scheme=data[2], expires=expires) + return self.get_auth_link(*data[:2], scheme=data[2], expires=expires, + client_method=client_method)