コード例 #1
0
ファイル: account.py プロジェクト: kartit/cloudProject
    def save_image(cls, photo, user_key=None):
        img_title = photo.filename
        img_content = photo.file.read()
        img_type = photo.type

        cloud_storage_path = "/gs/fooddonation/%s/%s" % (user_key.id(), img_title)
        blobstore_key = blobstore.create_gs_key(cloud_storage_path)
        print blobstore_key
        cloud_storage_file = cloudstorage_api.open(filename=cloud_storage_path[3:], mode="w", content_type=img_type)
        cloud_storage_file.write(img_content)
        cloud_storage_file.close()

        blobstore_key = blobstore.BlobKey(blobstore_key)
        serving_url = images.get_serving_url(blobstore_key)
        print serving_url
        return {"serving_url": serving_url, "blobstore_key": blobstore_key}
コード例 #2
0
ファイル: account.py プロジェクト: kartit/cloudProject
    def save_image(cls, photo, user_key=None):
        img_title = photo.filename
        img_content = photo.file.read()
        img_type = photo.type

        cloud_storage_path = '/gs/fooddonation/%s/%s' % (user_key.id(),
                                                         img_title)
        blobstore_key = blobstore.create_gs_key(cloud_storage_path)
        print blobstore_key
        cloud_storage_file = cloudstorage_api.open(
            filename=cloud_storage_path[3:], mode='w', content_type=img_type)
        cloud_storage_file.write(img_content)
        cloud_storage_file.close()

        blobstore_key = blobstore.BlobKey(blobstore_key)
        serving_url = images.get_serving_url(blobstore_key)
        print serving_url
        return {'serving_url': serving_url, 'blobstore_key': blobstore_key}
コード例 #3
0
    def save_image(cls, photo, user_key):
        img_title = photo.filename
        img_content = photo.file.read()
        img_type = photo.type
        #todd-search-images is a google cloud bucket
        cloud_storage_path = '/gs/todd-search-images/%s/%s' % (user_key.id(),
                                                               img_title)
        blobstore_key = blobstore.create_gs_key(cloud_storage_path)

        cloud_storage_file = cloudstorage_api.open(
            filename=cloud_storage_path[3:], mode='w', content_type=img_type)
        cloud_storage_file.write(img_content)
        cloud_storage_file.close()

        blobstore_key = blobstore.BlobKey(blobstore_key)
        serving_url = images.get_serving_url(blobstore_key)

        return {'serving_url': serving_url, 'blobstore_key': blobstore_key}
コード例 #4
0
    def save_image(cls, photo, user_key):
        img_title = photo.filename
        img_content = photo.file.read()
        img_type = photo.type
        #todd-search-images is a google cloud bucket
        cloud_storage_path = '/gs/todd-search-images/%s/%s' % (user_key.id(), img_title)
        blobstore_key = blobstore.create_gs_key(cloud_storage_path)

        cloud_storage_file = cloudstorage_api.open(
            filename=cloud_storage_path[3:], mode='w', content_type=img_type
        )
        cloud_storage_file.write(img_content)
        cloud_storage_file.close()

        blobstore_key = blobstore.BlobKey(blobstore_key)
        serving_url = images.get_serving_url(blobstore_key)

        return {
            'serving_url': serving_url,
            'blobstore_key': blobstore_key
        }