- Today
- Total
반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- deeplearning4j
- 이미지오류
- 인계동
- adverising
- 몽고디비 클론
- amozon
- secrets-manager-config
- opennlp
- unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
- Cannot have overlapping
- presigned
- 수원맛집
- 숲느낌
- python
- 데이트코스
- 수원
- java
- secrets manager
- 구 트위터
- Jakarta Persistence
- AWS
- 401error
- mongo to mysql
- secrets manager example code
- 주차가능
- Configuration is ambiguously defined. Cannot have overlapping suffixes in two rules if the prefixes are overlapping for the same event type.
- mongodb atlas
- Index 1 out of bounds for length 1
- source endpoint
- Cannot have overlapping suffixes in two rules if the prefixes are overlapping for the same event type.
Archives
DevOps-Life
[Python] AWS presignedUrl 만들기 본문
반응형
SMALL
JAVA에서는 post 방식을 지원하지 않아 찾아본 python 방식
업로드용 presign url을 만들기위한 베이직 소스
import logging
import boto3
from botocore.exceptions import ClientError
def create_presigned_post(bucket_name, object_name,
fields=None, conditions=None, expiration=3600):
"""Generate a presigned URL S3 POST request to upload a file
:param bucket_name: string
:param object_name: string
:param fields: Dictionary of prefilled form fields
:param conditions: List of conditions to include in the policy
:param expiration: Time in seconds for the presigned URL to remain valid
:return: Dictionary with the following keys:
url: URL to post to
fields: Dictionary of form fields and values to submit with the POST
:return: None if error.
"""
# Generate a presigned S3 POST URL
s3_client = boto3.client('s3')
try:
response = s3_client.generate_presigned_post(bucket_name,
object_name,
Fields=fields,
Conditions=conditions,
ExpiresIn=expiration)
except ClientError as e:
logging.error(e)
return None
# The response contains the presigned URL and required fields
return response
출처 : https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-presigned-urls.html
Presigned URLs - Boto3 1.34.90 documentation
Previous File transfer configuration
boto3.amazonaws.com
- bucket_name: 파일을 업로드할 S3 버킷의 이름입니다.
- object_name: 업로드할 파일의 경로와 이름을 나타냅니다.
- fields: 미리 채워진 양식 필드의 딕셔너리입니다. 이는 S3 POST 요청에 함께 제출할 양식 필드 및 값입니다.
- conditions: 정책에 포함할 조건의 목록입니다. 이는 POST 요청이 유효한지를 검증하는 데 사용됩니다.
- expiration: 사전 서명된 URL이 유효한 기간(초 단위)입니다.
JAVA 에서 PUT 일 경우 URL 에 Access key가 노출 되어
API Gateway 와 Lambda를 통하여 url 를 발급 받는 방법으로 해결하려 한다
끝!
반응형
LIST
'IT > Python' 카테고리의 다른 글
[Python] unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape (0) | 2023.09.14 |
---|
Comments