-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.htm
61 lines (55 loc) · 2.02 KB
/
index.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html>
<head>
<title>AWS S3 Upload</title>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="scripts/S3BlobUploader.js"></script>
</head>
<body>
<p>
<input type="file" id="file" accept="video/*">
<button onclick="upload()">Upload</button>
<button id="cancel" style="display: none;">Cancel</button>
</p>
<progress id="progress" value="0" max="100" style="width: 100%;"></progress>
<script>
var upload = function() {
var updateProgress = function(data) {
$('#progress').attr('value', data * 100);
}
var uploader = new S3BlobUploader({type : 'video', partSize : (5 * 1024 * 1024)});
uploader.on('beforeUpload', function() {
updateProgress(0);
console.log('preparing upload');
});
uploader.on('startUpload', function() {
console.log('upload starting');
});
uploader.on('progress', function(data) {
updateProgress(data);
});
uploader.on('progressStats', function(data) {
console.log(data);
});
uploader.on('finishing', function() {
console.log('Upload complete, preparing final file');
});
uploader.on('complete', function(data) {
console.log('We did it!', data);
});
uploader.on('error', function(data) {
console.log('failed', data);
alert('it failed :(');
});
uploader.on('cancel', function(data) {
console.log('cancelled', data);
});
$('#cancel').on('click', function() {
updateProgress(0);
uploader.abort();
}).show();
uploader.start($('#file')[0].files[0]);
}
</script>
</body>
</html>