我使用了GoogleAppEngineCloudStorageClient
Python库并使用类似于以下示例的代码加载了图像:
from google.appengine.api import app_identity import cloudstorage from flask import Flask, send_file import io, os app = Flask(__name__) # ... @app.route('/imagetest') def test_image(): # Use BUCKET_NAME or the project default bucket. BUCKET_NAME = '/' + os.environ.get('MY_BUCKET_NAME', app_identity.get_default_gcs_bucket_name()) filename = 'mytestimage.jpg' file = os.path.join(BUCKET_NAME, filename) gcs_file = cloudstorage.open(file) contents = gcs_file.read() gcs_file.close() return send_file(io.BytesIO(contents), mimetype='image/jpeg')