Issue with uploading Django CKEditor images to cloudinary
See original GitHub issueEverything is working fine if I don’t use Cloudinary. But when I am using Cloudinary for storing media files, it is throwing error:
Internal Server Error: /ckeditor/upload/
Traceback (most recent call last):
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\django\contrib\auth\decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\django\views\generic\base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\django\views\generic\base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\ckeditor_uploader\views.py", line 118, in post
saved_path = filewrapper.save_as(filepath)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\ckeditor_uploader\backends\pillow_backend.py", line 54, in save_as
saved_path = self.storage_engine.save(filepath, self.file_object)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\django\core\files\storage.py", line 52, in save
return self._save(name, content)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\cloudinary_storage\storage.py", line 68, in _save
response = self._upload(name, content)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\cloudinary_storage\storage.py", line 62, in _upload
return cloudinary.uploader.upload(content, **options)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\cloudinary\uploader.py", line 46, in upload
return call_cacheable_api("upload", params, file=file, **options)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\cloudinary\uploader.py", line 341, in call_cacheable_api
result = call_api(action, params, http_headers, return_error, unsigned, file, timeout, **options)
File "C:\Users\ashut\.virtualenvs\Blog-OHIX9BKG\lib\site-packages\cloudinary\uploader.py", line 428, in call_api
raise Error(result["error"]["message"])
cloudinary.exceptions.Error: Invalid image file
My urls patterns :
urlpatterns = [
path('admin/', admin.site.urls),
path('ckeditor/', include('ckeditor_uploader.urls')),
path('accounts/',include('authentication.urls')),
path('',include('core.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
My media files storage settings :
CLOUDINARY_STORAGE = {
'CLOUD_NAME': config("CLOUD_NAME"),
'API_KEY': config("API_KEY"),
'API_SECRET': config("API_SECRET")
}
# Media Files
MEDIA_ROOT = BASE_DIR / 'media'
MEDIA_URL = '/media/'
DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'
# CKEditor Configurations
CKEDITOR_UPLOAD_PATH = "blog/uploads/"
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How can i select from uploaded images in Cloudinary to add ...
I'm using CloudinaryField in Django to upload the Images to the Cloudinary. It works smooth no issues. But i want to be able...
Read more >CKEditor integration with Cloudinary Storage, browse server ...
Images upload worked well, but Browse Server always shows No images found. Upload images using the 'Image Button' dialog's 'Upload' tab.
Read more >can not upload image using Django-CKEditor (Error 400)
to be able to upload images, try this pip install django-ckeditor // or just make sure it is installed. in settings: INSTALLED_APPS =...
Read more >Image upload with Django and Cloudinary - Alpha Coder
Image upload with Django and Cloudinary. Managing files/images can be a hassle. It can be a real pain to have to deal with...
Read more >Enable Image Upload Button in ckeditor in Python/Django ...
I recently solved the same problem.First of all Upload tab is hidden in the image plugin dialog.You have to search for the upload...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ashutoshkrris cool, good news!
I found the solution. The main problem was, I was using Pillow as the Image backend. I removed it and it was resolved. Thanks for the help! Feel free to check it out : https://iread.ga