I want to access a file in my computer from a google app engine application. If I put the file in the src folder of the application there is no problem but I need this file to be out of that folder.
When I try to access this file I get the next error:
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'
I have read that if a file is defined as static in app.yaml can't be accessible from GAE. This is my app.yaml. I can't figure out if there is something wrong:
application: myapp
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: myapp.py
And this is the part of the application that tries to access the file:
filename='C:/Users/path_to_file/Documento 1.docx'
media_body = MediaFileUpload(filename,resumable=True)
Does someone know why do I get the "file not accessible" error?
Thanks!
Put the file in the same directory as the rest of your applications files (i.e. where the app.yaml is).
All the files you want your application to access have to be in the same place, under your main application directory.
GAE can't access arbitrary files somewhere on your computer, just like it cannot access files saved "somewhere" else when deployed.
filename='myfile.doc'
That's assuming it's in the 'root' (same as app.yaml).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With