简体   繁体   中英

Not able to read file content from google cloud storage in app engine

When I try to read content of a file (plain text) from Google Cloud Storage (App Engine, Python, Standard Env) I get the following trace:

raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))

Although 'Share Publicly' is set, I am working in the default bucket (the application should have full permissions to my understanding) and I am able to write/upload content to the same file.

As additional info I am triggering the request from an http route using GAE development server.

Could you point me to the right direction ? :D

Code is below:

def getDatastoreClient():
    projectId = 'xxxxxx'
    return storage.Client(projectId)

def readFileFromBucket(filename):
    # Instantiates a client
    storage_client = getDatastoreClient()

    # Creates the new bucket
    bucket = storage_client.get_bucket(BUCKETNAME)
    blob = bucket.get_blob(filename)
    return blob.download_as_string()

Latest versions of requests are not yet compatible with GCS. For now, downgrade your requests package to v2.3.0. Or, switch to using GAE's urlfetch

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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