Skip to content

Commit

Permalink
basic file up and download working
Browse files Browse the repository at this point in the history
  • Loading branch information
cle1000 committed Jun 1, 2016
1 parent 248e0f9 commit de8af07
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions mitmproxy/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def get(self):
sio.close()

def post(self):
# self.state.clear()
sio = StringIO(self.request.body)
self.state.load_flows(FlowReader(sio).stream())
sio.close()
Expand Down
21 changes: 16 additions & 5 deletions mitmproxy/web/static/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/src/js/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down
15 changes: 12 additions & 3 deletions web/src/js/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -372,7 +376,12 @@ var FileMenu = React.createClass({
</a>
</li>
<li>
<input type="file" onChange={this.handleOpenChange}/>
<a href="#" onClick={this.handleOpenClick}>
<i className="fa fa-fw fa-folder-open"></i>
Open...
</a>
<input id="uploadFileInput" className="hidden" type="file" onChange={this.handleOpenFile}/>

</li>
<li>
<a href="#" onClick={this.handleSaveClick}>
Expand Down

0 comments on commit de8af07

Please sign in to comment.