SWdream
SWdream

Reputation: 215

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. 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. For example this is a link of a stored image (blob):

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

But, it's just 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.

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?

Upvotes: 0

Views: 134

Answers (1)

ChrisC73
ChrisC73

Reputation: 1863

Local GCS data is stored in your local datastore, using the __GSFileInfo__ and __BlobInfo__ entities.

The same code is used for both Dev and Live App environments with no changes required.

Upvotes: 1

Related Questions