ダウンロードの場合は、必要に応じて Content-Disposition ヘッダーなど、必要なすべてのものと共に、ヘッダー "X-AppEngine-BlobKey:[your blob_key]" を含む応答を生成するだけで十分です。または、画像の場合は、おそらく高パフォーマンスの画像提供 API を使用し、URL を生成してリダイレクトする必要があります....完了
アップロードの場合、アップロードが安全にブロブストアにあるときに appengine が呼び出すハンドラーを作成することに加えて (ドキュメントに記載されています)
着信要求で BLOB 情報を見つける方法が必要です。リクエストがボトルでどのように見えるかわかりません。Blobstoreuploadhandler には get_uploads メソッドがあり、私が知る限り、インスタンス メソッドである必要がある理由はまったくありません。したがって、webob 要求を期待する一般的な実装の例を次に示します。ボトルの場合、ボトルリクエストオブジェクトと互換性のある同様のものを書く必要があります。
def get_uploads(request, field_name=None):
"""Get uploads for this request.
Args:
field_name: Only select uploads that were sent as a specific field.
populate_post: Add the non blob fields to request.POST
Returns:
A list of BlobInfo records corresponding to each upload.
Empty list if there are no blob-info records for field_name.
stolen from the SDK since they only provide a way to get to this
crap through their crappy webapp framework
"""
if not getattr(request, "__uploads", None):
request.__uploads = {}
for key, value in request.params.items():
if isinstance(value, cgi.FieldStorage):
if 'blob-key' in value.type_options:
request.__uploads.setdefault(key, []).append(
blobstore.parse_blob_info(value))
if field_name:
try:
return list(request.__uploads[field_name])
except KeyError:
return []
else:
results = []
for uploads in request.__uploads.itervalues():
results += uploads
return results