O
O
Oleg2016-08-02 15:35:54
Django
Oleg, 2016-08-02 15:35:54

How to process images in Django and then send them to a third-party host?

The process looks something like this:
- The user uploads an image from his computer via a web form
- The server receives the image, performs basic automatic processing (cropping, resizing), but does not save it in the database, but sends it to a third-party image hosting (in the first approximation - for example ,imgur). Then a link to the image address is entered into the database.
Interested in how easily such a scenario is implemented using Django; how applicable it is in conditions close to production, and whether there are alternative ways to work with images in conditions of limited file space on the hosting.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Sergeev, 2016-08-02
@SergeevAI

Elementary.
Having studied the API of the service to which the file will be uploaded.
For imgur https://api.imgur.com/endpoints/image
There is also an official library for python https://github.com/Imgur/imgurpython
We accept an image in a view, process it, convert it to a binary or base64 and send it to the service API .
In the case of the library, you will have to save it to the server, send it to imgur, and delete it from the server.

I
Ilya, 2016-08-02
@FireGM

Documentation is everything.
https://docs.djangoproject.com/en/1.9/howto/custom...
And also in Russian
https://www.youtube.com/watch?v=V--IL52n_fw
A bit outdated, but understand the principle and it won't be hard to implement.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question