简体   繁体   中英

upload to google cloud storage using libcloud

I wish to to upload files to google cloud storage. I created a service account, converted the p12 file to a pem file, then referenced the service account email address and pem file in my driver:

from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver


CloudStorage = get_driver(Provider.GOOGLE_STORAGE)
driver = CloudStorage(
    '...@developer.gserviceaccount.com',
    os.path.expanduser('~/.ssh/my.pem'),
    project='my_project',
)

however, when I do

driver.list_containers()

I get

<?xml version='1.0' encoding='UTF-8'?><Error><Code>InvalidSecurity</Code><Message>The provided security credentials are not valid.</Message><Details>Incorrect Authorization header</Details></Error>

apache-libcloud uses the S3 protocol for Google Storage.

This means you will need to enable Interoperability for Google Storage on the developer console.

Instructions for doing this and generating the keys are available here

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