fix: 修复S3预签名上传路径,移除固定前缀
This commit is contained in:
@@ -328,11 +328,11 @@ async def s3_presign_upload(body: UploadPresignRequest) -> UploadPresignResponse
|
|||||||
signed_url = client.generate_presigned_url("put_object",
|
signed_url = client.generate_presigned_url("put_object",
|
||||||
Params={
|
Params={
|
||||||
'Bucket': config.S3_bucket_name,
|
'Bucket': config.S3_bucket_name,
|
||||||
'Key': f"upload/{body.key}",
|
'Key': f"{body.key}",
|
||||||
"ContentType": body.content_type,
|
"ContentType": body.content_type,
|
||||||
}, ExpiresIn=expires_in, )
|
}, ExpiresIn=expires_in, )
|
||||||
return UploadPresignResponse(url=signed_url,
|
return UploadPresignResponse(url=signed_url,
|
||||||
urn=f"s3://{config.S3_region}/{config.S3_bucket_name}/upload/{body.key}",
|
urn=f"s3://{config.S3_region}/{config.S3_bucket_name}/{body.key}",
|
||||||
expired_at=expired_at)
|
expired_at=expired_at)
|
||||||
|
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ async def s3_presign_upload_multipart(body: UploadMultipartPresignRequest) -> Up
|
|||||||
signed_url = client.generate_presigned_url("upload_part",
|
signed_url = client.generate_presigned_url("upload_part",
|
||||||
Params={
|
Params={
|
||||||
'Bucket': config.S3_bucket_name,
|
'Bucket': config.S3_bucket_name,
|
||||||
'Key': f"upload/{body.key}",
|
'Key': f"{body.key}",
|
||||||
'PartNumber': i + 1,
|
'PartNumber': i + 1,
|
||||||
'UploadId': upload_id,
|
'UploadId': upload_id,
|
||||||
}, ExpiresIn=expires_in)
|
}, ExpiresIn=expires_in)
|
||||||
@@ -378,19 +378,19 @@ async def s3_presign_upload_multipart(body: UploadMultipartPresignRequest) -> Up
|
|||||||
signed_completed_url = client.generate_presigned_url("complete_multipart_upload",
|
signed_completed_url = client.generate_presigned_url("complete_multipart_upload",
|
||||||
Params={
|
Params={
|
||||||
'Bucket': config.S3_bucket_name,
|
'Bucket': config.S3_bucket_name,
|
||||||
'Key': f"upload/{body.key}",
|
'Key': f"{body.key}",
|
||||||
# 'PartNumber': chunk_count,
|
# 'PartNumber': chunk_count,
|
||||||
'UploadId': upload_id,
|
'UploadId': upload_id,
|
||||||
}, ExpiresIn=expires_in)
|
}, ExpiresIn=expires_in)
|
||||||
signed_list_url = client.generate_presigned_url("list_parts",
|
signed_list_url = client.generate_presigned_url("list_parts",
|
||||||
Params={
|
Params={
|
||||||
'Bucket': config.S3_bucket_name,
|
'Bucket': config.S3_bucket_name,
|
||||||
'Key': f"upload/{body.key}",
|
'Key': f"{body.key}",
|
||||||
# 'PartNumber': chunk_count,
|
# 'PartNumber': chunk_count,
|
||||||
'UploadId': upload_id,
|
'UploadId': upload_id,
|
||||||
}, ExpiresIn=expires_in)
|
}, ExpiresIn=expires_in)
|
||||||
return UploadMultipartPresignResponse(urls=signed_urls,
|
return UploadMultipartPresignResponse(urls=signed_urls,
|
||||||
urn=f"s3://{config.S3_region}/{config.S3_bucket_name}/upload/{body.key}",
|
urn=f"s3://{config.S3_region}/{config.S3_bucket_name}/{body.key}",
|
||||||
expired_at=expired_at,
|
expired_at=expired_at,
|
||||||
complete_url=signed_completed_url,
|
complete_url=signed_completed_url,
|
||||||
list_url=signed_list_url)
|
list_url=signed_list_url)
|
||||||
|
|||||||
Reference in New Issue
Block a user