(event)
return response
Function to generate the presigned GET url, that can be used to retrieve objects from s3 bucket
    Required Bucket Name and Object Name to generate url
Function to generate the presigned GET url, that can be used to retrieve objects from s3 bucket
    Required Bucket Name and Object Name to generate url
Function to generate the presigned GET url that can be used to retrieve objects from s3 bucket Required Bucket Name and Object Name to generate url
def signed_get_url(event):
    """Function to generate the presigned GET url, that can be used to retrieve objects from s3 bucket
    Required Bucket Name and Object Name to generate url
    """
    s3 = boto3.client('s3', region_name = 'eu-central-1',config=Config(signature_version='s3v4'))
    bodyData = json.loads(event['body'])
    try:
        url = s3.generate_presigned_url(ClientMethod='get_object',
                                        Params={'Bucket': bodyData["BucketName"],
                                                'Key':bodyData["ObjectName"]
                                               },
                                        ExpiresIn=int(globalVars['GetDefaultExpiry'])
                                        )
        # Browser requires this header to allow cross domain requests
        head = {"Access-Control-Allow-Origin" : "*" }
        body = { 'PreSignedUrl':url, 'ExpiresIn':globalVars['GetDefaultExpiry'] }
        response = {'statusCode': 200, 'body': json.dumps(body), 'headers':head}
    except Exception as e:
        logger.error('Unable to generate URL')
        logger.error('ERROR: {0}'.format( str(e) ) )
        response = {'statusCode': 502, 'body': 'Unable to generate URL', 'headers':head}
        pass
    return response
def signed_get_url ( event ) : s3 = boto3 . client ( 's3' , region_name = 'eu-central-1' , config = Config ( signature_version = 's3v4' ) ) bodyData = json . loads ( event [ 'body' ] ) try : url = s3 . generate_presigned_url ( ClientMethod = 'get_object' , Params = { 'Bucket' : bodyData [ "BucketName" ] , 'Key' : bodyData [ "ObjectName" ] } , ExpiresIn = int ( globalVars [ 'GetDefaultExpiry' ] ) ) # Browser requires this header to allow cross domain requests head = { "Access-Control-Allow-Origin" : "*" } body = { 'PreSignedUrl' : url , 'ExpiresIn' : globalVars [ 'GetDefaultExpiry' ] } response = { 'statusCode' : 200 , 'body' : json . dumps ( body ) , 'headers' : head } except Exception as e : logger . error ( 'Unable to generate URL' ) logger . error ( 'ERROR: {0}' . format ( str ( e ) ) ) response = { 'statusCode' : 502 , 'body' : 'Unable to generate URL' , 'headers' : head } pass return response