Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将文件从谷歌云存储加载到谷歌云功能_Python_Google Cloud Platform_Google Cloud Functions_Google Cloud Storage - Fatal编程技术网

Python 如何将文件从谷歌云存储加载到谷歌云功能

Python 如何将文件从谷歌云存储加载到谷歌云功能,python,google-cloud-platform,google-cloud-functions,google-cloud-storage,Python,Google Cloud Platform,Google Cloud Functions,Google Cloud Storage,我必须从存储在google cloud storage中的文件中读取数据,我使用此方法在我的GCP函数中加载文件,但这会导致错误 client = storage.Client() bucket = client.get_bucket('bulk-testing') blob = bucket.get_blob("h1.csv") blob.download_to_filename("h2") 错误:-下载到文件名以“wb”模式加载文件 错误:[Errno 30]只读文件系统:“h2” 此功能

我必须从存储在google cloud storage中的文件中读取数据,我使用此方法在我的GCP函数中加载文件,但这会导致错误

client = storage.Client()
bucket = client.get_bucket('bulk-testing')
blob = bucket.get_blob("h1.csv")
blob.download_to_filename("h2")
错误:-下载到文件名以“wb”模式加载文件 错误:[Errno 30]只读文件系统:“h2”


此功能未在本地计算机/环境中运行,因此无法在本地计算机上下载文件并打开它

如果需要在云函数中写入文件,则系统中唯一可写入的部分是/tmp。此空间由内存支持,因此您需要确保已为函数配置了足够的内存来写入文件

您可能应该调出要写入的文件的完整路径:

blob.download_to_filename("/tmp/h2")

如果需要在云函数中写入文件,系统中唯一可写入的部分是/tmp。此空间由内存支持,因此您需要确保已为函数配置了足够的内存来写入文件

您可能应该调出要写入的文件的完整路径:

blob.download_to_filename("/tmp/h2")

为我工作谢谢,还有一个问题我可以用h2写还是直接读?我不知道你在问什么。如何从内存中删除此文件/tmp/h2这是一个单独的问题,您应该已经能够找到很多答案了。但是类似于从pathlib导入路径;Pathtmp/h2.unlink应该有效如果你有一个单独的问题,那么请单独发布,而不是添加评论。对我有效谢谢,还有一个问题我可以用h2写还是我可以直接从中阅读?我不确定你在问什么。如何从内存中删除此文件/tmp/h2这是一个单独的问题,您应该已经能够找到很多答案了。但是类似于从pathlib导入路径;Pathtmp/h2.unlink应该可以工作如果你有一个单独的问题,那么请单独发布,而不是添加评论。