add download to issued cert
This commit is contained in:
27
http-api/app/routes/enrollments/download_issued_cert.py
Normal file
27
http-api/app/routes/enrollments/download_issued_cert.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from aws_lambda_powertools.event_handler.api_gateway import Router
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer
|
||||
|
||||
from boto3clients import dynamodb_client, s3_client
|
||||
from config import BUCKET_NAME, ENROLLMENT_TABLE
|
||||
|
||||
EXPIRES_IN = 300
|
||||
|
||||
router = Router()
|
||||
enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
|
||||
|
||||
|
||||
@router.get('/<id>/download')
|
||||
def download(id: str):
|
||||
params = {
|
||||
'Bucket': BUCKET_NAME,
|
||||
'Key': f'issuedcerts/{id}.pdf',
|
||||
'ResponseContentDisposition': f'attachment; filename="{id}.pdf"',
|
||||
}
|
||||
|
||||
return {
|
||||
'presigned_url': s3_client.generate_presigned_url(
|
||||
'get_object',
|
||||
Params=params,
|
||||
ExpiresIn=EXPIRES_IN,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user