我有一个URL,可以使用skimage.io接收并将其转换为图像。我正在尝试使用以下代码将此图像保存到Google存储桶:
class ImageStorage:
bucket_name = os.getenv('STORAGE_BUCKET_NAME')
project_name = os.getenv('STORAGE_BUCKET_PROJECT_ID')
client = storage.Client(project=project_name)
bucket = client.get_bucket(bucket_name)
def save_image(self, filename, image):
blob = self.bucket.blob(filename, chunk_size=262144)
blob.upload_from_file(image)
但是,我收到一个错误:
AttributeError: 'Array' object has no attribute 'tell'
错误跟踪如下:
Traceback (most recent call last):
File "C:\Users\xxxx\Miniconda3\lib\site-packages\graphql\execution\executor.py", line 450, in resolve_or_error
return executor.execute(resolve_fn, source, info, **args)
File "C:\Users\xxx\Miniconda3\lib\site-packages\graphql\execution\executors\sync.py", line 16, in execute
return fn(*args, **kwargs)
File "C:\Users\xxx.py", line 62, in mutate
newImageStorage.save_image(str(captchaId), image)
File "C:\Users\xxx.py", line 25, in save_image
blob.upload_from_file(image)
File "C:\Users\xxx\Miniconda3\lib\site-packages\gcloud\storage\blob.py", line 543, in upload_from_file
http_response = upload.stream_file(use_chunks=True)
File "C:\Users\xxx\Miniconda3\lib\site-packages\gcloud\streaming\transfer.py", line 1086, in stream_file
response = send_func(self.stream.tell())
该行在哪里中断:
response = send_func(self.stream.tell())
请多多指教:)