即時通訊嘗試上傳使用谷歌應用程序引擎urlfetch從url獲得的excel。我可以訪問它的所有標題。我現在需要將其上傳到blobstore。以下是運行時寫使用urlfetch上傳到blobstore
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)
的代碼,則返回錯誤「類型錯誤:不可轉位」
以下是我得到
頭備用的協議:80: quic,80:quily 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;文件名=「abc.xls」
這個Excel文件的URL從另一個Web應用程序
'fetch_thing'的代碼在哪裏? – loki
請檢查下面的答案,因爲您需要將您的文章編碼爲html格式才能上傳到blob。 – loki