Download image on heroku

Question:

i have a simple function in fastapi python

url="some_random_video_url_here"
re = requests.get(url)
with open("download/hello.png", 'wb') as file: #save hello.png to download folder
    file.write(re.content)
    file.close()

this function work locally fine and download image and any files bot when upload on heroku not download image and save in staticsFiles folder

please help

Asked By: Amir

||

Answers:

Heroku’s filesystem is ephemeral/short lived. This means that any images you save locally will disappear after you redeploy your app. You can’t rely on Heroku’s filesystem to store images that need to persist for a longer time.

For saving images, have a look at 3rd party storage solutions such as Cloudinary or AWS S3.

Answered By: Maxim Orlov
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.