この質問をテンプレートとして使用して同じ問題を解決しましたが、投稿時に問題が発生しています。私はこれらのコンポーネントを持っています:
- 画像 URL のテキストボックスを含むHTMLフォーム。この投稿先...
- 投稿された URL を受け取り、それをエンコードし、再度投稿するために使用するハンドラー
urlfetch
... - 実際の保存を行う個別のファイル アップロード ハンドラ。
ファイル入力を使用すると、コンポーネント #3 は単独で正常に動作します。urlfetch
しかし、画像の URL だけから必要なものを取得する方法がよくわかりません。プロセスがタイムアウトするか、最終ハンドラーから 500 応答を受け取ります。
# 1
class URLMainHandler(RequestHandler):
def get(self):
return render_response('blob/upload_url.html',
upload_url=url_for('blobstore/upload/url'))
# 2
class URLUploadHandler(RequestHandler):
def post(self):
import urllib
# Get the posted image URL.
data = urllib.urlencode({'file': self.request.form.get('file')})
# Post image to blobstore by calling POST on the file upload handler.
result = urlfetch.fetch(url=blobstore.create_upload_url(url_for('blobstore/upload')),
payload=data,
method=urlfetch.POST)
return self.redirect(url_for('blobstore/url'), result.status_code)
# 3
class UploadHandler(RequestHandler, BlobstoreUploadMixin):
def post(self):
# 'file' is the name of the file upload field in the form.
upload_files = self.get_uploads('file')
blob_info = upload_files[0]
response = redirect_to('blobstore/serve', resource=blob_info.key())
# Clear the response body.
response.data = ''
return response
繰り返しますが、これは私が従うプロセスです。ご協力いただきありがとうございます!