Created
November 4, 2016 04:48
-
-
Save yoshihiko-ikenaga/ddcb8428628cfea9db47531251869e3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_onFileChanged(e) { | |
let f = new FormData(); | |
// TODO set the attribute name | |
f.append('video[video]', e.target.files[0]); | |
var xhr = new XMLHttpRequest(); | |
xhr.addEventListener("load", () => { | |
xhr.complete = true; | |
// TODO Next action | |
}); | |
xhr.addEventListener('progress', (evt) => { | |
if (evt.lengthComputable) { | |
let percentComplete = (evt.loaded / evt.total) * 100.0; | |
logger.debug(`Upload status: ${percentComplete}%`); | |
// TODO update progress bar | |
} | |
}); | |
xhr.open("POST", '/videos.json', true); | |
xhr.responseType = 'json'; | |
xhr.setRequestHeader('X-CSRF-Token', $('meta[name=csrf-token]').attr('content')); | |
xhr.send(f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment