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

时间:2019-11-27 05:32:45

标签: python google-cloud-platform google-cloud-functions google-cloud-storage

我必须从存储在Google云端存储中的文件中读取数据,我正在使用此方法将文件加载到我的GCP函数中,但这会导致错误

       NotificationManager notif=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notify=new Notification.Builder
           (getApplicationContext()).setContentTitle(tittle).setContentText(body).
           setContentTitle(subject).setSmallIcon(R.drawable.abc).build();

           notify.flags |= Notification.FLAG_NO_CLEAR;
           notif.notify(0, notify);

错误:-download_to_filename以“ wb”模式加载文件 错误:[Errno 30]只读文件系统:“ h2”

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

1 个答案:

答案 0 :(得分:2)

如果需要在Cloud Functions中写入文件,则系统唯一可写的部分在/ tmp中。 Read the documentation about this.该空间由内存支持,因此您需要确保已为该功能配置了足够的内存来写入文件。

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

blob.download_to_filename("/tmp/h2")