From a219d3343081e13a005fc37e30a0bab83a773099 Mon Sep 17 00:00:00 2001 From: Clemens Date: Wed, 1 Jun 2016 23:12:49 +0200 Subject: [PATCH] basic file up and download working --- mitmproxy/web/app.py | 1 + web/src/js/actions.js | 2 +- web/src/js/components/header.js | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mitmproxy/web/app.py b/mitmproxy/web/app.py index afeb7c001..43949cc76 100644 --- a/mitmproxy/web/app.py +++ b/mitmproxy/web/app.py @@ -178,6 +178,7 @@ class DumpFlows(RequestHandler): sio.close() def post(self): + # self.state.clear() sio = StringIO(self.request.body) self.state.load_flows(FlowReader(sio).stream()) sio.close() diff --git a/web/src/js/actions.js b/web/src/js/actions.js index 0f81d7a38..2f2479799 100644 --- a/web/src/js/actions.js +++ b/web/src/js/actions.js @@ -122,7 +122,7 @@ export var FlowActions = { upload: (file) => { var filereader = new FileReader(); filereader.file = file; - filereader.onload = (e) => $.post("/flows/dump", e.target.result); + filereader.onload = (e) => {$.post("/flows/dump", e.target.result); e.preventDefault();}; filereader.readAsBinaryString(file); } }; diff --git a/web/src/js/components/header.js b/web/src/js/components/header.js index 4bb4622d3..859f2fcf0 100644 --- a/web/src/js/components/header.js +++ b/web/src/js/components/header.js @@ -344,11 +344,15 @@ var FileMenu = React.createClass({ } }, handleOpenClick: function (e) { + $('#uploadFileInput').trigger('click'); e.preventDefault(); }, - handleOpenChange: function (e) { + handleOpenFile: function (e) { + if (e.target.files.length > 0) { + FlowActions.upload(e.target.files[0]); + $('#uploadFileInput').val(""); + } e.preventDefault(); - FlowActions.upload(e.target.files[0]); }, handleSaveClick: function (e) { e.preventDefault(); @@ -372,7 +376,12 @@ var FileMenu = React.createClass({
  • - + + + Open... + + +