Django-ckeditor RichTextUploadingField не загружает изображения в ведро s3
Я пытаюсь загрузить свои изображения через RichTextUploadingField в ведро s3, но изображение не загружается:
INSTALLED_APPS = [
...
'bootstrap4',
'imagekit',
'storages', #aws
'taggit',
'ckeditor',
'ckeditor_uploader',
...
]
CKEDITOR_UPLOAD_PATH = "uploads/"
CKEDITOR_BASEPATH = "/static/ckeditor/ckeditor/"
CKEDITOR_IMAGE_BACKEND = "pillow"
CKEDITOR_BROWSE_SHOW_DIRS = True
CKEDITOR_CONFIGS = {
...
}
MIDDLEWARE = [
...
'whitenoise.middleware.WhiteNoiseMiddleware'
]
AWS_ACCESS_KEY_ID = var_getter('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = var_getter('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = var_getter('AWS_STORAGE_BUCKET_NAME')
AWS_S3_SIGNATURE_NAME = var_getter("AWS_S3_SIGNATURE_NAME")
AWS_S3_REGION_NAME = var_getter("AWS_S3_REGION_NAME")
AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.{AWS_S3_REGION_NAME}.amazonaws.com'
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_S3_FILE_OVERWRITE = False
AWS_DEFAULT_ACL = 'public-read'
AWS_QUERYSTRING_AUTH = False for images from s3
# AWS_DEFAULT_ACL = None
AWS_S3_VERIFY = True
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / 'static'
MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/uploads/'
MEDIA_ROOT = 'uploads/'
Это мой model.py
from django.db import models
from django.urls import reverse
from taggit.managers import TaggableManager
from ckeditor_uploader.fields import RichTextUploadingField
from ckeditor.fields import RichTextField
from imagekit.models import ImageSpecField, ProcessedImageField
from imagekit.processors import ResizeToFill
class Article(models.Model):
"""Articles under section """
STATUS_CHOICES = (
('draft', 'Draft'),
('published', 'Published'),
)
section = models.ForeignKey(Section, on_delete=models.CASCADE, null=False, blank=False)
topic = models.CharField(max_length=200)
slug = models.SlugField(unique=True, blank=False)
body = RichTextUploadingField(blank=True, null=True,
external_plugin_resources=[(
'youtube',
'/static/youtube/youtube/',
'plugin.js',
)]
)
date_added = models.DateTimeField()
thumb = ProcessedImageField(upload_to='thumbs_/%Y/%m/',
processors=[ResizeToFill(800, 458)],
blank=True,
null=True,
format='PNG',
options={'quality': 100}
)
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft')
objects = models.Manager() # The default manager.
published = PublishedManager() # custom manager.
tags = TaggableManager()
Вот мои разрешения в s3:
{
"Version": "2012-10-17",
"Id": "Policy1727540",
"Statement": [
{
"Sid": "Stmt1721435",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucketname/*"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::******:user/username"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::bucketname",
"arn:aws:s3:::bucketname/*"
]
}
]
}
Here, is IAM permission for user:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:*",
"s3-object-lambda:*"
],
"Resource": "*"
}
]
}
Когда я пытаюсь загрузить изображения с помощью shell, это работает. Версии Django==5.1.1, django-ckeditor==6.7.1, django-storages==1.14.4.
Может ли кто-нибудь подсказать, почему он не работает?
Я поиграл с разрешениями в aws, установил AWS CLI. Попробовал понизить версию CKEditor и Django.