インタフェースからバイナリストリームデータを返す
2634 ワード
import StringIO
class ImplementOutIo(Handler):
def get():
filepath ="/home/bolome/qa_test/bolo-server/internal/bin/jiji.zip"
f = open(filepath, 'rb')
# ,
fio = StringIO.StringIO(f.read())
# ,
self.set_header('Content-Type', 'application/octet-stream')
#
self.set_header("Content-Disposition", 'attachment;filename=will.zip')
# bytes
self.write(fio.getvalue())
#
fb = zipfile.ZipFile(file=fio)