Skip to content

Instantly share code, notes, and snippets.

View yoshihiko-ikenaga's full-sized avatar

Yoshihiko Ikenaga yoshihiko-ikenaga

View GitHub Profile
_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
validFile(file, success, error) {
const MAX_VIDEO_SIZE = 1024 * 1024 * 100;
const MAX_VIDEO_DURATION = 30;
const SIZE_ERROR = 1;
const DURATION_ERROR = 2;
if (file.size() > MAX_VIDEO_SIZE) {
error(SIZE_ERROR);
return;
}