'Django ckeditor 5 upload images to Google Cloud Bucket
I am trying to use the package django-ckeditor-5 on my webapp.
I am using django-storages with storages.backends.gcloud.GoogleCloudStorage backend. I have set these settings:
CKEDITOR5_FILE_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage' CKEDITOR_5_UPLOADS_FOLDER = 'uploads/'
However, when I try to upload an image, I get this error:
Internal Server Error: /ckeditor5/image_upload/
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/stokk/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/opt/homebrew/Caskroom/miniforge/base/envs/stokk/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/homebrew/Caskroom/miniforge/base/envs/stokk/lib/python3.9/site-packages/django_ckeditor_5/views.py", line 54, in upload_file
url = handle_uploaded_file(request.FILES["upload"])
File "/opt/homebrew/Caskroom/miniforge/base/envs/stokk/lib/python3.9/site-packages/django_ckeditor_5/views.py", line 41, in handle_uploaded_file
fs = storage(location=uploads_path)
File "/opt/homebrew/Caskroom/miniforge/base/envs/stokk/lib/python3.9/site-packages/storages/backends/gcloud.py", line 97, in __init__
check_location(self)
File "/opt/homebrew/Caskroom/miniforge/base/envs/stokk/lib/python3.9/site-packages/storages/utils.py", line 93, in check_location
if storage.location.startswith('/'):
AttributeError: 'PosixPath' object has no attribute 'startswith'
[04/May/2022 15:00:20] "POST /ckeditor5/image_upload/ HTTP/1.1" 500 105904
Other relevant settings:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
django-ckeditor4 worked fine, so is it a question of supporting GCB storage or am I missing something in my settings?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
