Reputation: 548
I am trying to upload image/file to clodinary to get back the url using this code
medical_file = request.FILES['medical_file']
out = cloudinary.uploader.upload(File.open(medical_file, "rb"))
url = out['url']
medical_file_url = url
And I am successfully getting the url as well(I have printed that on my console)
But then I am getting this error of : cloudinary.api.Error: Empty file
Upvotes: 2
Views: 945
Reputation: 151
Per Cloudinary's documentation:
In cases where images are uploaded by users of your Django application through a web form, you can pass the parameter of your Django's request.FILES to the upload method
So in your case, you can upload the file on the server-side by passing request.FILES['medical_file']
directly to the upload method:
out = cloudinary.uploader.upload(request.FILES['medical_file'])
Upvotes: 2