2017-01-30 1 views
0

PillowImage 인스턴스를 Firebase 스토리지 버킷에 업로드하는 방법을 알아 내려고하고 있습니다. 이것이 가능한가? 내가 거기 gcloud-python 라이브러리입니다하지만 Image 경우이 지원을하지 알고Python : Firebase 스토리지 버킷에 베개 이미지 업로드

from PIL import Image 

image = Image.open(file) 
# how to upload to a firebase storage bucket? 

: 여기

는 일부 코드입니까? 이미지를 문자열로 변환하는 유일한 방법은 무엇입니까?

답변

1

gcloud-python 라이브러리는 올바른 라이브러리입니다. 파일 시스템에서 문자열, 파일 포인터 및 로컬 파일의 업로드를 지원합니다 (the docs 참조).

from PIL import Image 
from google.cloud import storage 

client = storage.Client() 
bucket = client.get_bucket('bucket-id-here') 
blob = bucket.blob('image.png') 
# use pillow to open and transform the file 
image = Image.open(file) 
# perform transforms 
image.save(outfile) 
of = open(outfile, 'rb') 
blob.upload_from_file(of) 
# or... (no need to use pillow if you're not transforming) 
blob.upload_from_filename(filename=outfile) 
+0

''gs : // example.appspot.com '또는' 'example.appspot.com' '처럼 보이는'bucket-id-here''가 표시됩니까? – rigdonmr

+0

그냥'example.appspot.com' :) –

관련 문제