user1930068 user1930068 - 2 years ago 55
Python Question

IOError: [Errno 13] file not accessible GAE

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\", line 712, in __call__*groups)
File "C:\Users\path\Documents\path\oauth2client\", line 469, in check_oauth
return method(request_handler, *args, **kwargs)
File "C:\Users\path\Documents\path\", 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\", 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

- url: /.*

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?


Answer Source

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.


That's assuming it's in the 'root' (same as app.yaml).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download