반응형
해결 방법
from gcloud import storage
from oauth2client.service_account import ServiceAccountCredentials
import os
credentials_dict = {
'type': 'service_account',
'client_id': os.environ['BACKUP_CLIENT_ID'],
'client_email': os.environ['BACKUP_CLIENT_EMAIL'],
'private_key_id': os.environ['BACKUP_PRIVATE_KEY_ID'],
'private_key': os.environ['BACKUP_PRIVATE_KEY'],
}
credentials = ServiceAccountCredentials.from_json_keyfile_dict(
credentials_dict
)
client = storage.Client(credentials=credentials, project='myproject')
bucket = client.get_bucket('mybucket')
blob = bucket.blob('myfile')
blob.upload_from_filename('myfile')
참조 페이지 https://stackoverflow.com/questions/37003862
반응형
'파이썬' 카테고리의 다른 글
파이썬에서 하나의 if 문에 대해 여러 조건을 갖는 방법 (0) | 2020.11.04 |
---|---|
파이썬 숫자 열 정렬 (표 형식으로 출력 인쇄) (0) | 2020.11.04 |
파이썬 What to download in order to make nltk.tokenize.word_tokenize work? (0) | 2020.11.04 |
파이썬 Compare 2 excel files using Python (0) | 2020.11.04 |
파이썬 사전에서 무작위로 하나의 키를 선택하는 방법 (0) | 2020.11.04 |
댓글