经过大量时间的努力后,我得出了解决方案:{
def presign_post_S3_url(self, key=None, is_public=False):
acl = 'private'
if is_public:
acl = 'public-read'
fields = {"acl": acl, "Content-Type": "video/mp4"}
conditions = [
{"acl": acl},
["starts-with", "$Content-Type", ""]
]
if key is None:
return ""
##s3_client is boto3.client object
s3_client = self.get_s3_client()
if s3_client is None:
return ""
data = s3_client.generate_presigned_post(
Bucket=self.bucket,
Key=key,
Fields=fields,
Conditions=conditions
)
return data
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1130 次 |
| 最近记录: |