简体   繁体   English

Google App Engine-Google App Engine开发环境和应用程序环境有什么区别

[英]Google app engine - What is the different between google app engine dev environment and application environment

Have a nice day. 祝你今天愉快。

I am trying to write a application use google app engine and python to save and retrieve an image to google cloud storage. 我正在尝试使用Google App Engine和python编写应用程序以保存图像并将其检索到Google云存储。 I researched and I know that, the dev environment is quite different with the application environment such as: when I write code for dev, I no need to declare user for authentication.... So, it means the dev code and the app code are different. 经过研究,我知道开发环境与应用程序环境完全不同,例如:当我为开发人员编写代码时,无需声明用户进行身份验证...。因此,这意味着开发人员代码和应用程​​序代码是不同的。

for example about my dev code: 例如关于我的开发代码:

BUCKET_NAME = os.environ.get('BUCKET_NAME',
                             app_identity.get_default_gcs_bucket_name())
BUCKET = '/' + BUCKET_NAME

logger.debug('BUCKET_NAME: %s' % BUCKET_NAME)

def create_file(filename, filedata, **kwargs):
    """
    Create a file.
    :param filename:
    :param filedata:
    :param kwargs:
    :return:
    """
    bucket_filename = BUCKET + '/' + filename
    write_retry_params = gcs.RetryParams(backoff_factor=1.1)
    gcs_file = gcs.open(bucket_filename,
                        'w',
                        content_type=kwargs.get('content_type', 'image/jpeg'),
                        options=kwargs.get('options', {}),
                        retry_params=write_retry_params)
    gcs_file.write(filedata)
    gcs_file.close()

    blobstore_filename = '/gs' + bucket_filename
    return blobstore.blobstore.create_gs_key(blobstore_filename)

This function will create and save a file to localhost datastore. 此函数将创建文件并将其保存到localhost数据存储。 For example this is a link of a stored image (blob): 例如,这是存储的图像(blob)的链接:

http://localhost:8000/datastore/edit/blob_key  

But, it's just LOCALHOST. 但是,这只是LOCALHOST。 And I don't understand the way a file (image) will be created, stored and retrieved to google cloud storage in a application environment. 而且我不了解在应用程序环境中文件(图像)的创建,存储和检索到Google云存储的方式。

This isn't clear for me. 这对我来说还不清楚。

Could you please help me to explain more detail about the different between dev environment and app environment? 您能帮我解释一下开发环境和应用程序环境之间的区别的更多细节吗? And how to use dev code in app environment? 以及如何在应用程序环境中使用开发代码?

Local GCS data is stored in your local datastore, using the __GSFileInfo__ and __BlobInfo__ entities. 本地GCS数据使用__GSFileInfo__ and __BlobInfo__实体存储在本地数据存储中。

The same code is used for both Dev and Live App environments with no changes required. Dev和Live App环境使用相同的代码,无需进行任何更改。

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

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