我希望从Google应用程序引擎访问我的计算机中的文件。如果我将文件放在应用程序的src文件夹中,那么就没有问题,但是我需要这个文件不在那个文件夹中。
当我尝试访问这个文件时,我会得到下一个错误:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\_webapp25.py", line 712, in __call__
handler.post(*groups)
File "C:\Users\path\Documents\path\oauth2client\appengine.py", line 469, in check_oauth
return method(request_handler, *args, **kwargs)
File "C:\Users\path\Documents\path\myapp.py", line 88, in post
filename=open('C:/Users/path_to_file/Documento 1.docx','r')
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 635, in __init__
raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: 'C:/Users/path_to_file/Documento 1.docx'
我读到过,如果一个文件在app.yaml中被定义为静态文件,则无法从GAE访问。这是我的app.yaml文件,我无法确定是否有问题:
application: myapp
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: myapp.py
这是应用程序尝试访问文件的部分:
filename='C:/Users/path_to_file/Documento 1.docx'
media_body = MediaFileUpload(filename,resumable=True)
有人知道为什么我会得到“文件不可访问”的错误吗?
谢谢!