class PDF(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = "application/txt"
self.response.headers['Content-Disposition'] = "attachment; filename=file.pdf"
f = open('/Users/BP/file.pdf', 'r')
self.response.out.write(f.read())
def main():
application = webapp.WSGIApplication([('/download', PDF)],
debug=False)
util.run_wsgi_app(application)
I get this error when I try to download it:
[Errno 13] Permission denied: '/Users/BP/file.pdf'
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 701, in __call__
handler.get(*groups)
File "/base/data/home/apps/s~projectname/1.354763951774324185/main.py", line 43, in get
f = open('/Users/BP/file.pdf', 'r')
IOError: [Errno 13] Permission denied: '/Users/BP/file.pdf'
Even though I've tried the chmod a+r file.pdf
Help please. Thank you!