Skip to content

Commit 58556ac

Browse files
committed
feat(video-uploader): Allow custom video name
1 parent fee77ad commit 58556ac

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

sample/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88

99
<form>
1010
<input type="file" id="input" onchange="uploadFile(this.files)">
11+
<input type="text" id="VideoName" placeholder="Video name">
1112
</form>
1213
<script type="text/javascript">
1314
function uploadFile(files) {
15+
const videoName = document.getElementById('VideoName').value
1416
const uploader = new VideoUploader({
1517
file: files[0],
16-
uploadToken: "to7EcLLzRSsqhkzxyIhavEHA" // ecosystem sandbox upload token
18+
uploadToken: "to7EcLLzRSsqhkzxyIhavEHA", // ecosystem sandbox upload token
19+
videoName: videoName
1720
});
1821

1922
uploader.upload()

src/video-uploader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AbstractUploader, CommonOptions, DEFAULT_CHUNK_SIZE, MAX_CHUNK_SIZE, MI
22

33
interface UploadOptions {
44
file: File;
5+
videoName?: string;
56
chunkSize?: number;
67
}
78

@@ -39,7 +40,7 @@ export class VideoUploader extends AbstractUploader<UploadProgressEvent> {
3940
this.chunkSize = options.chunkSize || DEFAULT_CHUNK_SIZE;
4041
this.file = options.file;
4142
this.fileSize = this.file.size;
42-
this.fileName = this.file.name;
43+
this.fileName = options.videoName || this.file.name;
4344

4445
this.chunksCount = Math.ceil(this.fileSize / this.chunkSize);
4546
}

0 commit comments

Comments
 (0)