I´m trying to save an uploaded jpg in a Shini app, but I can´t find the way.
I upload and image correctly with Fileinput. No problem there.
I want to be able to save that image in the server to use it in the future.
How can I do this?
Thankls!!!
Related
How can I create a video and photo uploading feature on my website using Python and Django?
I have using forms,models(file_field) and yet it doesn't render to the front_end
If you're using ImageField to upload to the server, make sure you have pillow installed. Your python may just be looking at a wrong path to search for your files. Secondly, you might want to consider your markup code, and make sure that there is space for your video to be uploaded. ie) , etc..
I have a model with a FileField for document uploads (e.g. images, pdfs, or videos). I use this line in my Document model:
storage_file_name = models.FileField('File name', upload_to=unique_file_path)
and in unique_file_path I change the name of the uploaded document to a unique file name. I find that I will be uploading some tiffs, which I need to change to jpeg or something that a browser can easily display.
I have been looking for the best way to convert the uploaded tiff file to jpeg. Is there a way to do it before the image is saved to the disk, or is the best way to use a
#receiver(models.signals.post_save, sender=Document)
and save the converted image over the saved tiff image?
At this point I am only using the admin pages and not any custom views (except by customizing the admin pages).
Thanks!
Mark
May be somebody faced with such issue and found good solution. I need rotate image in template before upload and save the record. I can rotate image view in template using JavaScript but it doesn't give any results, because image saves in original rotation. I saw several sites with such kind of feature and it's really useful.
You cannot get rotated image from Django templates. I assume you are working on a web app, where user uploads an image, rotates it and then saves it to later use. This can be done in the following way.
There is a lib for working with images in Python called PIL. You can use it in your view, which saves your image to the db. When a user plays with an image, use javascript for rotations on the front end. But when saving, let javascript send angles to the view and then make according changes to the uploaded image and then save to the db.
Links: How to use PIL for rotation in Python
For my Python app,I had completed the basic settings to interact with google drive api and found it working by a test upload of a CSV file. Now I need to upload an image from a url to a newly created folder named 'myappname' in Google Drive.
Thanks in advance
For now, there is no way you can directly upload file from url. There are two workaround I can think of
Download file and upload it back using Files.insert()
Use Save to Drive button
Using save to Drive button requires user interaction to click the button which might not be the one you want. In that case, downloading and uploading is the only way I can think of.
I am looking to have an entry form where you can enter in a server name and end up getting several png images displayed that are created from matpotlib.
I can create the form, and have the scripts written that create the image files. I am wondering what the best way to deal with the images are. Is there a way I can display the resulting png file to the browser but not save it to disk?
Want to avoid cluttering up a directory with the generated images after they are displayed the the browser. Should I just delete the image after its rendered?
response = HttpResponse(mimetype="image/png")
img.save(response, "PNG")
return response