Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

623
Visualizações
How Can I upload All types of files (videos, audios, pdfs, zip) in cloudinary in django model ? and how can i delete them?

models.py

from django.db import models
from cloudinary.models import CloudinaryField

class File(models.Model):
    caption = models.TextField(blank=True)
    file = CloudinaryField()

    # trying to delete the File model and cloudinary file (error)
    def delete(self, *args, **kwargs):
        self.file.delete(*args, **kwargs)
        super().delete(*args, **kwargs)

settings.py

import cloudinary
import cloudinary.uploader
import cloudinary.api

...

INSTALLED_APPS = [
    '....',

    'myapp',
    'cloudinary',
]

...

cloudinary.config( 
  cloud_name = "...", 
  api_key = "...", 
  api_secret = "...",
  secure = True
)

i can upload images only, when i try to upload any (video, pdf, audio, zip) it says INVALID IMAGE FILE. and sometimes file size error occurs when image size exceeds 10 mb size limit.

This is The Error i am facing. (when i tried to upload a video file)

Error at /
Invalid image file
Request Method: POST
Request URL:    http://127.0.0.1:8000/
Django Version: 3.2.9
Exception Type: Error
Exception Value:    
Invalid image file
Exception Location: C:\Users\MIG 29\Desktop\Project\testCloudinary\vEnv\lib\site-packages\cloudinary\uploader.py, line 522, in call_api
Python Executable:  C:\Users\MIG 29\Desktop\Project\testCloudinary\vEnv\Scripts\python.exe
Python Version: 3.9.6
Python Path:    
['C:\\Users\\MIG 29\\Desktop\\Project\\testCloudinary',
 'c:\\users\\mig 29\\appdata\\local\\programs\\python\\python39\\python39.zip',
 'c:\\users\\mig 29\\appdata\\local\\programs\\python\\python39\\DLLs',
 'c:\\users\\mig 29\\appdata\\local\\programs\\python\\python39\\lib',
 'c:\\users\\mig 29\\appdata\\local\\programs\\python\\python39',
 'C:\\Users\\MIG 29\\Desktop\\Project\\testCloudinary\\vEnv',
 'C:\\Users\\MIG '
 '29\\Desktop\\Project\\testCloudinary\\vEnv\\lib\\site-packages']
Server time:    Sun, 05 Dec 2021 06:14:04 +0000
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

thank me, i just found the way to upload (images, videos, audios) too.. it goes like this. in models.py

file = CloudinaryField(resource_type='')
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda