8

I am playing with Google App Engine and Python and I cannot list the files of a static directory. Below is the code I currently use.

app.yaml

- url: /data
  static_dir: data

Python code to list the files

myFiles = []
for root, dirs, files in os.walk(os.path.join(os.path.dirname(__file__), 'data/') ):
    for name in files:
        full_name = os.path.join(root, name)
        myFiles.append('%s;%s\n' % (name, datetime.fromtimestamp(os.stat(full_name).st_mtime)))

When I run this code locally on my machine, everything is alright. I have my Python script at the root of the directory and it walks the files under the data directory. However, when I upload and run the exact same code in GAE, it doesn`t work. It seems to me that the directory structure of my application is not exactly replicated in Google App Engine. Where are the static files?

Thanks!

4

3 に答える 3

7

https://developers.google.com/appengine/docs/python/config/appconfig#Python_app_yaml_Static_file_handlers

GAE は、CDN に相当する GoogleFS に静的コンテンツを配置します。静的コンテンツは、ユーザーに直接提供することを意図しており、操作可能なファイル ストアとしては機能しないという考え方です。さらに、GAE には 1K のファイル制限があり、静的ファイル ストアを操作できる場合、このルールを監視することは困難です。

于 2009-01-25T16:23:31.993 に答える