POST Request - Web Service

I’m pretty new with using Render and uploading flask API, I tried doing GET request and it works. But I have this POST request which user need to upload a file, I want to know where does the uploaded file go? does it temporary holds until the request finished? Thanks in advance🎉

@app.route("/upload", methods=['POST'])
def upload():
    f = request.files['file']
    f.save(secure_filename(f.filename))

    return "Upload successfully!"

Hi,

I’ve replied to the ticket you also opened. Uploads will save wherever your code specifies to save them.

However, Render instances have an ephemeral filesystem, meaning any file written to the instance after it has booted will be lost when it next restarts (e.g. spun down if on free instance type, next deploy, manual restart, etc.).

If you want to use file uploads on your service, you’ll need to have a persistent store, e.g. a Render Disk (which is chargeable and also require a paid instance type) or an external service like AWS S3.

Alan

I didn’t specify where it will be stored, I will just use my flask API so I can upload the uploaded file to another API (like bridge). So, basically it will not be stored in Render? Lastly, will my plan work if I do the bridge stuff I wanna do? I apologize, I kinda new to some of the words. Thanks for explaining🎉

The Flask documentation on uploading shows setting an upload folder: https://flask.palletsprojects.com/en/2.3.x/patterns/fileuploads/

If you want to store the uploads between service restarts, you’ll need a disk, with the upload folder in the code pointing to the “Mount Path” of the disk.

Alan

Thank you very much, for explaining🎉

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.