我用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