I am writing the backend code of a website in which there are movies and tv shows. And each film has a poster which can be used on the frontend. these posters are saved in a specific directory folder (let's say "\Posters").
What I need is an API that sends back an image (for example "Jumanji 2017.jpg") using a url like .../Poster/Jumanji_2017.jpg or .../Poster/Jumanji%202017.jpg or anything that would resemble the movie title.
Is there anyway I could do this? (preferably without making an image model)
If you know the
BASE_URLin which you will save the images as when you deploy you could save then on an external bucket (storage) then you can make something like this:but there is another approach you can use when you don't know or you don't care about the bucket(storage) url where image is saved:
for this one you have to
import base64and then in your front end you can load image as base64 like thisPs. In the first example
obj.image.urlis the path of the image in the bucket (let it be whatever), but you need the full path to load it on the front end side.