URLを指定すると、ファイルがダウンロードされ、ブロブストアにブロブとして保存されるプロセスをGAEを使用して作成したいと考えています。これが完了したら、このブロブを POST データとして 2 番目の URL に渡したいと思います。ただし、この 2 番目の部分が機能するには、BLOB をファイル インスタンスとして開くことができる必要があります。
最初の部分のやり方が分かった
from __future__ import with_statement
from google.appengine.api import files
imagefile = urllib2.urlopen('fileurl')
# Create the file
file_name = files.blobstore.create(mime_type=imagefile.headers['Content-Type'])
# Open the file and write to it
with files.open(file_name, 'ab') as f:
f.write(imagefile.read())
# 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)
しかし、2番目の部分を行う方法がわかりません。これまで私は試しました
ffile = files.open(files.blobstore.get_file_name(blob_key), 'r')
from google.appengine.ext import blobstore
ffile = blobstore.BlobReader(blob_key)
from google.appengine.ext import blobstore
ffile = blobstore.BlobInfo.open(blobstore.BlobInfo(blob_key))
そのすべてが を与えFalse
ますisinstance(ffile, file)
。
どんな助けでも大歓迎です。