0
heroku의 사전 서명 된 요청을 사용하여 S3에 직접 업로드하는 방법에 대한 heroku 설명서 (https://devcenter.heroku.com/articles/s3-upload-python)를보고 있습니다.heroku에서 사전 서명 된 요청 받기
아래의 코드에서 실제 파일을 Heroku로 보내서 미리 서명 된 요청을 얻으 려합니까 아니면 파일 정보 (이름, 유형 등)를 보낼 수 있습니까?
@app.route('/sign_s3/')
def sign_s3():
S3_BUCKET = os.environ.get('S3_BUCKET')
file_name = request.args.get('file_name')
file_type = request.args.get('file_type')
s3 = boto3.client('s3')
presigned_post = s3.generate_presigned_post(
Bucket = S3_BUCKET,
Key = file_name,
Fields = {"acl": "public-read", "Content-Type": file_type},
Conditions = [
{"acl": "public-read"},
{"Content-Type": file_type}
],
ExpiresIn = 3600
)
return json.dumps({
'data': presigned_post,
'url': 'https://%s.s3.amazonaws.com/%s' % (S3_BUCKET, file_name)
})