I'm using Flask Uploads for an upload form in my Flask application. However, whenever I try to save a file I get this error:
File "/Users/Documents/virtual_environment/bin/../lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/app'
It seems like uploads doesn't have the necessary permissions to save files? Here's the configuration I'm using for flask-uploads:
UPLOADS_DEFAULT_URL = os.environ.get("UPLOADS_URL", "http://localhost:5000/")
UPLOADS_DEFAULT_DEST = "/app/uploads/"
UPLOAD_EXTENSIONS = set(["csv", "xls", "xsls"])
Also, here's how I save the actual file:
@app.route('/upload', methods = ['GET', 'POST'])
@app.route('/upload/', methods = ['GET', 'POST'])
@roles_accepted('admin', 'team')
def r_upload():
form = FileUploadForm()
if form.validate_on_submit():
filename = uploadSet.save(form.uploadfile.data)
url = uploadSet.url(filename)
flash("%s uploaded <a href=\'%s\'>HERE</a>!" % (filename, url))
return render_template('/uploads.html',
dashboard_title = "%s Uploads" % g.name,
form = form)
The error is caused by the save line. Any suggestions on how to fix this? Thanks.