将Blob_values传输到队列

时间:2013-04-23 14:18:49

标签: python google-app-engine blob

我无法将blob_name传输到我的队列,因此我可以在那里读出信息并进行处理。 Blob的信息或内容基本上只是文本列表(CSV)。我也尝试使用blob_key,但两者都会导致同样的错误。

# I create the blob - works fine, checked in Dashboard

    file_name = files.blobstore.create(mime_type='text/comma-separated-values',_blobinfo_uploaded_filename=str(datetime.now()))
    with files.open(file_name, 'a') as f:
        f.write(low)
    files.finalize(file_name)


# Transferring the variables to the queue

    taskqueue.add(url='/filtering_brands', params={'filter_name' : filter_name, 'user' : user, 'lowkey' : file_name})

    self.redirect('/?sent=True')

class Queue(webapp2.RequestHandler):
  def post(self):

# Requesting the variables
    filter_name = self.request.get('filter_name')
    user = self.request.get('user')
    lowkey = self.request.get('lowkey')
    blob_key = files.blobstore.get_blob_key(lowkey)

# This is (apparently) the part that doesn't work
    low = blobstore.BlobReader(blob_key)

# Process the data and transfer it to an email script

这是我收到的错误:

TypeError: object of type 'BlobReader' has no len()

1 个答案:

答案 0 :(得分:1)

看起来您忘记了指定blob_key名称参数。 试试这个:

blob_key = files.blobstore.get_blob_key(blob_key = str(lowkey))