『비전공자도 이해할 수 있는 챗GPT』,
『비전공자도 이해할 수 있는 AI 지식』
10만 베스트셀러를 기록한
세상에서 가장 이해하기 쉬운 챗GPT 교양서

HOME » WIKI » GCS

GCS

Google Cloud Storage

Cloud Storage에 올려두고 로컬에 파일이 없을 경우 다운로드.

import os
from google.cloud import storage

BUCKET = "bucket"
PATH = '/ml-experiments'
FILE = 'sample.csv'

client = storage.Client()
if not os.path.exists(PATH + '/' + FILE):
    bucket = client.get_bucket(BUCKET)
    blob = bucket.blob(FILE)
    blob.download_to_filename(PATH + '/' + blob.name)

    print('Downloaded to {}'.format(PATH + '/' + blob.name))

업로드 과정도 동일. blob에 gcs 파일명, upload에 로컬 파일명

client = storage.Client()
bucket = client.get_bucket(BUCKET)
blob = bucket.blob('X.pkl')
blob.upload_from_filename(os.getcwd() + '/X.pkl')
Last Modified: 2021/12/18 01:13:51
자바 알고리즘 인터뷰 파이썬 알고리즘 인터뷰

카카오 코딩 테스트 출제위원이 직접 집필한,
리트코드(LeetCode) 문제로 풀어보는,
구글, 마이크로소프트, 네이버, 카카오
코딩 테스트 완벽 가이드
『자바 알고리즘 인터뷰』,
『파이썬 알고리즘 인터뷰』

이 사이트의 운영 비용을 후원할 수 있으며, 후원자에게 혜택을 제공할 예정입니다.

© 2000 - Sang Park Except where otherwise noted, content on this site is licensed under a CC BY-NC 4.0.
This site design was brought from Distill. Logo and wiki background image was brought from Bear.