Empty File
I'm rtying to upload an image and as it is clear by the logs the field is not empty , however on submiting form I'm getting an error (Emty File). I'm sure that the code has no problem since its working on local. following is the log from debug mode :
<UploadedFile: be4ab90e-6fa3-48b3-b6fa-78dafa4ecbbb.jpg (None)>
'media/images/be4ab90e-6fa3-48b3-b6fa-78dafa4ecbbb.jpg'
<cloudinary_storage.storage.MediaCloudinaryStorage object at 0x7fe3662d2748>
some technical information :
hosted on heroku
using django
-
Hi,
I've checked our backend logs and as far as I can tell, we're not receiving any data in the file.Can you share some more about how you're sending the file? The code you're using to send the upload API call, if possible?
Are you able to debug the HTTP request which is being made and see if the file is being sent but in the wrong parameter, is your python process able to read the file on disk, etc?
Thanks,
Stephen0 -
Hi,
I traced the stack and find out where the problem is :
def save(self, *args, **kwargs):
if self.post_preview_image:
"""
compressing image
"""
new_image = compress(self.post_preview_image)
self.post_preview_image = new_image
super().save(*args, **kwargs)I'm compressing this image and this function can not find the image to compress. how can I fetch the image pass it to this function ?
0 -
Can you please let me know some more information about what you're doing in this workflow?
Is that 'compress image' function uploading the file to Cloudinary and then downloading it again with transformations applied like adjusting the quality level or size, or do you want to download a file from your Cloudinary account and pass it to a local function?
What value are you seeing for 'self.post_preview_image' before and after calling the compress function? is it a file stored in your Cloudinary account?
0 -
I didn't know that it is possible to compress images with Cloudinary . But, to clarify why I'm using this local function is to read the image and then compress it. The thing you mentioned here "to download a file from your Cloudinary account and pass it to a local function?" is what I wanted. I appreciate if you can also tell me how to compress images with cloudinary as well.
Thnaks,
Iliya
0 -
Hi Lliya,
Cloudinary provides media optimizations. You can use f_auto and q_auto which automatically compresses the image while making sure the visual quality is kept and it also has the ability to automatically detect which browser is requesting the image and then selecting the most efficient image format to deliver.
There are even more tips that can help you optimize your bandwidth consumption even further, for more information:
https://support.cloudinary.com/hc/en-us/articles/202521522-How-can-I-make-my-images-load-faster-
http://cloudinary.com/documentation/image_optimizationRegards,
Aditi0
Post is closed for comments.
Comments
5 comments