FileNotFoundError: [Errno 2] No such file or directory (Using Google Cloud Shell Editor)

1k Views Asked by At

I make upload files CSV using flask framework to insert data CSV into the database, I'm using google cloud shell editor but I got an error like this "No such file or directory: 'files/{file_csv_name}'"

This is my code for upload:

# I make a folder named "files"
UPLOAD_FOLDER = 'files/'
app.config['UPLOAD_FOLDER'] =  UPLOAD_FOLDER

if request.method == 'POST':
    # this request to get file uploaded using dropzone.js
    f = request.files['file']
    # and then this for access the path for save the file
    file_path = os.path.join(app.config['UPLOAD_FOLDER'], f.filename)
    # I allow file only csv
    if f and allowed_file(f.filename):
        f.save(file_path)
        # process inputing data into database
        hasil = parseCSV(file_path)
        return render_template("testes.html", data=hasil)
    else:
        os.remove(file_path)
        return render_template("testes.html", data="Oh no")

and I deployed my app in the google cloud run. I don't know why I can't access the path or I can't found the folder, or must I use google cloud storage? I write all my code in google cloud shell too. Any suggestion for this error?

0

There are 0 best solutions below