im trying to upload an excel that is obtained from a url using google app engine urlfetch. I can access all its headers. I now need to upload the same into the blobstore. The following is the code i wrote
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)
when run, it returns an error "TypeError: not indexable"
The following are the headers i got
alternate-protocol: 80:quic,80:quic server: Google Frontend transfer-encoding: chunked date: Mon, 21 Jul 2014 13:18:16 GMT content-type: application/msexcel cache-control: no-cache content-transfer-encoding: Binary content-disposition: attachment; filename="abc.xls"
this excel file url is obtained from another webapp
fetch_thing
? – loki