I am trying to create a little server in Google Cloud Platform that receives an image and put it in Storage.
But when server is deploying always writes in logs the same error:
ImportError: cannot import name storage at (/base/data/home/apps/my_environment/my_server:000000000000000.000000000000000000/main.py:15) at LoadObject (/base/alloc/tmpfs/dynamic_runtimes/python27/8882c914eb6132e9_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:85) at _LoadHandler (/base/alloc/tmpfs/dynamic_runtimes/python27/8882c914eb6132e9_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:299) at Handle (/base/alloc/tmpfs/dynamic_runtimes/python27/8882c914eb6132e9_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:240)
My function is like this:
from google.cloud import storage
...
def post_icon(request):
file = request.files['file']
package = request.form['package']
if file and _allowed_file(file.filename):
gcs = storage.Client()
bucket = gcs.get_bucket(CLOUD_STORAGE_APP_ICONS_SEGMENT)
blob = bucket.blob(file.filename)
blob.upload_from_string(
file.read(),
content_type=file.content_type
)
return {'code': 200 , 'message': blob.public_url }
else:
return {'code': 400 }
Can someone help me?