File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/stac_auth_proxy/handlers Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 33import logging
44import re
55from dataclasses import dataclass
6+ from typing import Literal
67
78import boto3
89from botocore .exceptions import ClientError
@@ -16,17 +17,20 @@ class S3AssetSigner:
1617 bucket_pattern : str = r".*"
1718 max_expiration : int = 3600
1819
19- def endpoint (self , payload : "S3AssetSignerPayload" , expiration : int = 3600 ) -> str :
20+ def endpoint (
21+ self , payload : "S3AssetSignerPayload" , expiration : int = 3600
22+ ) -> dict [Literal ["signed_url" ], str ]:
2023 """Generate a presigned URL to share an S3 object."""
2124 if not re .match (self .bucket_pattern , payload .bucket_name ):
2225 return HTTPException (status_code = 404 , detail = "Item not found" )
2326
2427 try :
25- return boto3 .client ("s3" ).generate_presigned_url (
28+ url = boto3 .client ("s3" ).generate_presigned_url (
2629 "get_object" ,
2730 Params = {"Bucket" : payload .bucket_name , "Key" : payload .object_name },
2831 ExpiresIn = min (expiration , self .max_expiration ),
2932 )
33+ return {"signed_url" : url }
3034 except ClientError as e :
3135 logging .error (e )
3236 return HTTPException (status_code = 500 , detail = "Internal server error" )
You can’t perform that action at this time.
0 commit comments