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 向blobstore写入Blob_Python_Google App Engine_Blobstore - Fatal编程技术网

Python 向blobstore写入Blob

Python 向blobstore写入Blob,python,google-app-engine,blobstore,Python,Google App Engine,Blobstore,我正在尝试使用下面描述的方法写入blobstore: 我尝试使用remote_api执行以下代码: file_name = files.blobstore.create(mime_type='text/html',_blobinfo_uploaded_filename='sample.txt') with files.open(file_name, 'a') as f: f.write('sample text for the sample blob') files.finalize(

我正在尝试使用下面描述的方法写入blobstore:

我尝试使用remote_api执行以下代码:

file_name = files.blobstore.create(mime_type='text/html',_blobinfo_uploaded_filename='sample.txt')
with files.open(file_name, 'a') as f:
    f.write('sample text for the sample blob')
files.finalize(file_name)
总是引发错误(在上面的第三行):

回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“C:\ProgramFiles(x86)\Google\Google\U appengine\Google\appengine\api\File
s\file.py”,第310行,写入
self.\u进行\u rpc\u调用\u并重试('Append',request,response)
文件“C:\ProgramFiles(x86)\Google\Google\U appengine\Google\appengine\api\File
s\file.py”,第388行,在_make_rpc_call_with_retry中
_调用(方法、请求、响应)
文件“C:\ProgramFiles(x86)\Google\Google\U appengine\Google\appengine\api\File
s\file.py”,第236行,在_make_call中
_提升应用程序错误(e)
文件“C:\ProgramFiles(x86)\Google\Google\U appengine\Google\appengine\api\File
s\file.py“,第179行,在_raise_app_错误中
raise FILENOTPENEDERROR()
FileNotOpenedError

我试图编写的文件非常小(<20KB),因此它不是配额问题。是否缺少其他步骤?

也许您需要在模块下方添加,但如果您之前没有添加

    from __future__ import with_statement 
 -->from google.appengine.api import files
    from google.appengine.ext import blobstore
    from google.appengine.ext.webapp import blobstore_handlers


    file_name = files.blobstore.create(mime_type='text/plain',_blobinfo_uploaded_filename='sample.txt')
    with files.open(file_name, 'a') as f:
         f.write('sample text for the sample blob') 
    files.finalize(file_name)

您似乎也在尝试从交互式shell执行此操作。哪里您正在输入什么代码?更新了代码,是的,我正在通过远程api执行。我需要这样做,因为我需要使用我的自定义bulkloader创建blob。
    from __future__ import with_statement 
 -->from google.appengine.api import files
    from google.appengine.ext import blobstore
    from google.appengine.ext.webapp import blobstore_handlers


    file_name = files.blobstore.create(mime_type='text/plain',_blobinfo_uploaded_filename='sample.txt')
    with files.open(file_name, 'a') as f:
         f.write('sample text for the sample blob') 
    files.finalize(file_name)