Reputation: 381
I build a django application that generates an image and places it in a folder on the server. I want to download that image, located on the server at example.com/generatedimages
. How do I send this image to the client? What does it have to do with static files? Do I need to generate a URL for that image temporarily? I do not use Django templating.
Technical information:
.png
and .svg
Thanks in advance.
Upvotes: 0
Views: 1433
Reputation: 1380
If the file is placed in settings.MEDIA_ROOT
then it is publicly available and you can use settings.MEDIA_URL
to create a link.
If the file is outside of settings.MEDIA_ROOT
, you can use built-in view django.views.static.serve.
If you need some protection, just use standard view but return FileResponse.
Serving large files through Django is not efficient. If you need large files, check django-sendfile.
Upvotes: 1