(event)
return response
Function to generate the presigned post url, that can be used to upload objects to s3 bucket
    Required Bucket Name and Object Name to generate url
Function to generate the presigned post url, that can be used to upload objects to s3 bucket
    Required Bucket Name and Object Name to generate url
Function to generate the presigned post url that can be used to upload objects to s3 bucket Required Bucket Name and Object Name to generate url
def signed_post_url(event):
    """Function to generate the presigned post url, that can be used to upload objects to s3 bucket
    Required Bucket Name and Object Name to generate url
    """
    s3 = boto3.client('s3')
    import uuid
    bodyData = json.loads(event['body'])
    # Add random prefix - Although not necessary to improve s3 performance, to avoid overwrite of existing objects.
    fName = uuid.uuid4().hex + '_' + bodyData['FileName']
    try:
        post = s3.generate_presigned_post(Bucket=bodyData["BucketName"],
                                          Key=fName,
                                          ExpiresIn=int(globalVars['PostDefaultExpiry'])
                                        )
        # Browser requires this header to allow cross domain requests
        head = {"Access-Control-Allow-Origin" : "*" }
        post['ExpiresIn'] = globalVars['PostDefaultExpiry']
        response = {'statusCode': 200, 'body': json.dumps(post), 'headers':head}
    except Exception as e:
        logger.error('Unable to generate PUT Url')
        logger.error('ERROR: {0}'.format( str(e) ) )
        response = {'statusCode': 502, 'body': 'Unable to generate URL', 'headers':head}
        pass
    return response
def signed_post_url ( event ) : s3 = boto3 . client ( 's3' ) import uuid bodyData = json . loads ( event [ 'body' ] ) # Add random prefix - Although not necessary to improve s3 performance, to avoid overwrite of existing objects. fName = uuid . uuid4 ( ) . hex + '_' + bodyData [ 'FileName' ] try : post = s3 . generate_presigned_post ( Bucket = bodyData [ "BucketName" ] , Key = fName , ExpiresIn = int ( globalVars [ 'PostDefaultExpiry' ] ) ) # Browser requires this header to allow cross domain requests head = { "Access-Control-Allow-Origin" : "*" } post [ 'ExpiresIn' ] = globalVars [ 'PostDefaultExpiry' ] response = { 'statusCode' : 200 , 'body' : json . dumps ( post ) , 'headers' : head } except Exception as e : logger . error ( 'Unable to generate PUT Url' ) logger . error ( 'ERROR: {0}' . format ( str ( e ) ) ) response = { 'statusCode' : 502 , 'body' : 'Unable to generate URL' , 'headers' : head } pass return response