I use cloudinary as the default media storage for my Django project so I just setup it like this:
settings.py
INSTALLED_APPS = [
'cloudinary'
]
DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'
CLOUDINARY_STORAGE = {
'CLOUD_NAME': os.environ.get('CLOUDINARY_STORAGE.CLOUD_NAME'), # env is set right
'API_KEY': os.environ.get('CLOUDINARY_STORAGE.API_KEY'),
'API_SECRET': os.environ.get('CLOUDINARY_STORAGE.API_SECRET'),
}
so now if I want to setup an ImageField I have no problems with that just with default Django syntax:
image = ImageField(upload_to=get_image_upload_path,
max_length=255)
but when I want to store a file in my way it's video file:
video = FileField(upload_to=get_video_upload_path,
max_length=255)
I get this error: Invalid image file
which means that Django using cloudinary storage tries to upload this file as an image what's set as the default behavior to cloudinary.
So my questions is if there is anyway to tell cloudinary gloabally to automatically decide what type of the file is?