【发布时间】:2012-01-01 00:08:17
【问题描述】:
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)
当我尝试下载它时出现此错误:
[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'
尽管我已经尝试过chmod a+r file.pdf
请帮忙。谢谢!
【问题讨论】: