【发布时间】:2021-11-19 15:24:14
【问题描述】:
我有一个包含一些 pdf 文件的 GCP 存储桶。 我可以使用以下代码在本地主机上使用 python(flask) 从存储桶下载文件-
storage_client = storage.Client.from_service_account_json("ebillaae7f0224519.json")
bucket = storage_client.get_bucket("bill_storage1")
blob = bucket.blob(file_name)
blob.download_to_filename("file1.pdf")
但当部署在 GCP(应用程序引擎)上时,我收到此错误“第 1282 行,在 download_to_filename 中,open(filename, "wb") as file_obj: OSError: [Errno 30] Read-only file system: 'file1.pdf '" 然后我将代码修改为 -
storage_client = storage.Client.from_service_account_json("ebillaae7f0224519.json")
bucket = storage_client.get_bucket("bill_storage1")
blob = bucket.blob(file_name)
blob.download_to_filename("/tmp/file1.pdf")
这在部署后有效,但我无法通过我的应用程序将文件从存储桶下载到本地文件夹,该怎么做?
【问题讨论】:
-
问题已更新
标签: python google-app-engine google-cloud-platform