[CSAPI] boto3 관련 스크랩

[CSAPI] boto3 관련 스크랩

django file form 업로드 시, 바로 s3로 저장

https://stackoverflow.com/questions/59891320/valueerror-filename-must-be-a-string-while-uploading-file-to-s3-bucket

s3.upload_file 대신 s3.upload_fileobj 사용

head object 와 botocore 를 사용한 버킷 오브젝트 검색 및 예외처리

import boto3 from botocore.errorfactory import ClientError s3 = boto3.client('s3') try: s3.head_object(Bucket='bucket_name', Key='file_path') except ClientError: # Not found pass

https://stackoverflow.com/questions/33842944/check-if-a-key-exists-in-a-bucket-in-s3-using-boto3

https://stackoverflow.com/questions/33842944/check-if-a-key-exists-in-a-bucket-in-s3-using-boto3

from http://not-to-be-reset.tistory.com/547 by ccl(A) rewrite - 2021-12-12 20:01:23