我试图上传一个excel,这是从一个网址,使用谷歌应用程序引擎urlfetch。我可以访问它的所有标头。我现在需要上传同样的东西到小商店。下面是我写的代码
class Send_Handler(webapp2.RequestHandler):
def get(self):
url = "http://abc.xls"
result = None
fetch_(url, result, 'GET')
# self.response.out.write(result.content)
def fetch_(url, result, method):
# logging.info(result)
if method=='GET':
result = urlfetch.fetch(url)
if result.status_code == 200:
upload_url = blobstore.create_upload_url('/attachupload')
logging.info(upload_url)
fetch_(upload_url, result, 'POST')
else:
try:
r_headers = result.headers
logging.info(result.content)
result_2 = urlfetch.fetch(url=url, payload=result.content,method=urlfetch.POST, headers=r_headers)
# logging.info(result_2)
except Exception, e:
logging.error(e)运行时,它返回一个错误"TypeError: not “。
以下是我得到的标题
替代协议: 80:quic,80:quic服务器: Google前端传输编码:分组日期: Mon,2014年7月21日13:18:16 GMT内容类型: application/msexcel缓存控制:无缓存内容传输编码:二进制内容处理:附件;filename="abc.xls“
此excel文件url来自另一个webapp。
发布于 2014-07-22 01:36:34
几个月前,我写了这个要旨,内容是使用upload_url和urlfetch将一个blob上传到blob商店。示例代码从blob存储区读取现有的blob。
要将blob发送到blob商店,您必须发送多个部件/表单数据。
https://stackoverflow.com/questions/24866798
复制相似问题