我用this question作爲模板來解決同樣的問題,但是我在發帖時遇到了問題。我有這些組件:如何將Web圖像保存到App Engine的blobstore?
- HTML 形式帶有圖像URL的文本框。這個職位,以...
- 一個處理,是以貼出網址,對其進行編碼,並使用
urlfetch
再次發佈它... - 單獨文件上傳處理,做實際節能。
如果我使用文件輸入,組件#3本身工作正常。但我不太明白如何從圖片網址獲得urlfetch
的需求。我的流程要麼超時,要麼得到最終處理程序的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
再次,this is the process I'm following。謝謝你的幫助!
#2處理程序只有30秒來獲取文件並將其上傳到blobstore處理程序。 – systempuntoout 2011-03-20 21:00:18