I have stored all images in folder \uploads. I have stored filename + extension in database. Each image has name PHOTO_ID.jpeg. I have some query on items and to those items I connect photo by its id. I want send JSON response something like this that contains url for image.
WANTED RESPONSE: json:{name: 'somename' url: 'imageURL'}
So question is how to get URL that can be accessible from one user only. I don't want to anybody be able to guess url of others image. I found some methods in FLASK but they need to be bind to some endpoint. I don't want explicit endpoint for retrieving url of images. These methods I found so far:
send_from_directory(DIRECTORY,FILENAME)
url_for(endpoint, filename=filename)
send_file(FILEPATH,'image/' + extension, as_attachment=True)
I want something simple like this retrieve_url(FILEPATH)
that will return url and secure approach only for one user.
Thank you for your help.