繁体   English   中英

为什么Google Cloud Storage quickstart.py可以在Google Cloud Shell上运行而不在Google App Engine上运行?

[英]Why Google Cloud Storage quickstart.py works on google cloud shell but not on Google App Engine?

Google Cloud Storage quickstart.py可在Google Cloud Shell上运行,但不能在Google App Engine上运行

quickstart.py

def run_quickstart():
    # [START storage_quickstart]
    # Imports the Google Cloud client library
    from google.cloud import storage
    # Instantiates a client
    storage_client = storage.Client()
    bucket_name = 'mygoolgeappproject.appspot.com'
    bucket = storage_client.get_bucket(bucket_name)
    blobs = bucket.list_blobs()`enter code here`
    for blob in blobs:
        print(blob.name)
    # The name for the new bucket
    #bucket_name = 'mygoolgeappproject.appspot.com'
    # Creates the new bucket
    #bucket = storage_client.create_bucket(bucket_name)
    #print('Bucket {} created.'.format(bucket.name))
    # [END storage_quickstart]

if __name__ == '__main__':
    run_quickstart()

您不能直接将GAS应用程序直接运行诸如quickstart.py类的普通python脚本。 不同目的的不同工具。

您需要一个基本的GAE应用框架。 您可以在Hello World代码审查中找到示例框架。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM