Как отладить S3direct с помощью django
в settings.py
AWS_ACCESS_KEY_ID = *************
AWS_SECRET_ACCESS_KEY = **************
AWS_STORAGE_BUCKET_NAME = "my-bucket-develop-whitebear"
S3DIRECT_DESTINATIONS = {
'images': {
# "key" [required] The location to upload file
# 1. String: folder path to upload to
# 2. Function: generate folder path + filename using a function
'key': resource.create_filename,
'key_args': 'my-assets/images',
# "auth" [optional] Limit to specfic Django users
# Function: ACL function
'auth': lambda u: u.is_authenticated,
# "allowed" [optional] Limit to specific mime types
# List: list of mime types
'allowed': ['image/jpeg', 'image/png'],
'acl': 'private',
# "cache_control" [optional] Custom cache control header
# String: header
'cache_control': 'max-age=2592000',
# "content_disposition" [optional] Custom content disposition header
# String: header
'content_disposition': lambda x: 'attachment; filename="{}"'.format(x),
# "content_length_range" [optional] Limit file size
# Tuple: (from, to) in bytes
'content_length_range': (10, 10000000), # 10MB
# "server_side_encryption" [optional] Use serverside encryption
# String: encrytion standard
'server_side_encryption': 'AES256',
# "allow_existence_optimization" [optional] Checks to see if file already exists,
# returns the URL to the object if so (no upload)
# Boolean: True, False
'allow_existence_optimization': False,
},
'videos': {
'key': resource.create_filename,
'key_args': 'my-assets/videos',
'auth': lambda u: u.is_authenticated,
'allowed': ['video/mp4'],
'acl': 'private',
'content_length_range': (10, 200000000), # 200MB
}
}
в файле forms.py
class ResourceCreateForm(BaseModelForm):
image = forms.URLField(widget=S3DirectWidget(dest='images'), required=False)
class Meta:
model = Resource
fields = ['image']
AdministratorAccess прикреплен к пользователю IAM, и S3 разрешен открытый доступ.
Когда я устанавливаю jpg в форму, в консоли появляется несколько одинаковых сообщений, как показано ниже,
[INFO][220125 230810] Found credentials in environment variables.
[25/Jan/2022 23:08:10] "POST /s3direct/get_aws_v4_signature/ HTTP/1.1" 200 80
После нескольких минут ожидания ничего не происходит.
Я хочу исследовать причины, однако нет никаких сообщений об ошибках.
Есть ли какая-нибудь хорошая практика, чтобы проверить журнал или показать некоторые подсказки в консоли?