Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.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 将文件写入google app engine blobstore,因为这些方法将被弃用_Python_Google App Engine_Blobstore - Fatal编程技术网

Python 将文件写入google app engine blobstore,因为这些方法将被弃用

Python 将文件写入google app engine blobstore,因为这些方法将被弃用,python,google-app-engine,blobstore,Python,Google App Engine,Blobstore,我想把从网络上获取的一些数据保存到blobstore,但是google文档说 不推荐使用:此处用于将文件写入Blobstore的文件API功能将在将来某个时候删除,以便将文件写入Google云存储并使用Blobstore为其提供服务 python中的代码如下所示 from __future__ import with_statement from google.appengine.api import files # Create the file file_name = files.blob

我想把从网络上获取的一些数据保存到blobstore,但是google文档说

不推荐使用:此处用于将文件写入Blobstore的文件API功能将在将来某个时候删除,以便将文件写入Google云存储并使用Blobstore为其提供服务

python中的代码如下所示

from __future__ import with_statement
from google.appengine.api import files

# Create the file
file_name = files.blobstore.create(mime_type='application/octet-stream')

# Open the file and write to it
with files.open(file_name, 'a') as f:
  f.write('data')

# Finalize the file. Do this before attempting to read it.
files.finalize(file_name)

# Get the file's blob key
blob_key = files.blobstore.get_blob_key(file_name)

我想知道是否有另一种方式来写blobstore而不是官方的上传方法

如果你想使用像API这样的文件,你必须使用GCS

Blobstore用于上传或多或少的静态图像并为其提供服务

如果您想使用类似API的文件进行编写,然后从Blobstore提供服务,则可以向GCS进行写入,并向该文件获取BlobKey


但是像你想的那样向BlobStore写信是不可取的。停止尝试这样做。

一个选项可能是使用TextProperty将数据放入数据存储中,因为blobstore正在消失,因此api被弃用。您是否阅读了有关CAN存储客户端librbry的入门指南?其代码在示例中显示了类似于api的文件。我想将文件存储在blobstore而不是云存储中。是的,但blobstore正在消失。您可以继续使用它和api,直到服务器关闭它为止。因此,我还没有听到任何关于blobstore离开的消息,官方有没有提到这一点@TimHoffman,但是是的,我认为gsc客户端库不支持写入blobstore,除了不推荐使用的文件api。