I'm running a Flask application on Apache2 server on Ubuntu. The application would take input from a form and save it to a text file. The file exists only for the moment when it's uploaded to S3. After that it's deleted.:
foodforthought = request.form['txtfield']
with open("filetos3.txt", "w") as file:
file.write(foodforthought)
file.close()
s3.Bucket("bucketname").upload_file(Filename = "filetos3.txt", Key = usr+"-"+str(datetime.now()))
os.remove("filetos3.txt")
but the app doesn't have permission to create the file:
[Errno 13] Permission denied: 'filetos3.txt'
I already tried to give permissions to the folder where the app is located with:
sudo chmod -R 777 /var/www/webApp/webApp
but it doesn't work