Commit 26fa0202 authored by liujiangnan's avatar liujiangnan

feat

parent 39b2e852
......@@ -33,7 +33,7 @@
:before-upload="beforeUpload"
:on-change="handleFileChange"
:on-error="handleUploadError"
accept="video/*">
accept=".mp4,video/mp4,application/mp4">
<el-button type="primary" :loading="uploading" :disabled="uploading">选择视频</el-button>
<span class="hint">支持重复上传,会覆盖当前视频</span>
</el-upload>
......
......@@ -82,13 +82,27 @@ new Vue({
}
},
methods: {
/** 仅允许 .mp4;MIME 有值时须为 video/mp4 或 application/mp4(部分环境 type 为空则只靠扩展名) */
isMp4File: function (file) {
var raw = file && file.raw ? file.raw : file;
if (!raw || !raw.name) {
return false;
}
if (!/\.mp4$/i.test(raw.name)) {
return false;
}
var t = (raw.type || '').toLowerCase();
if (t && t !== 'video/mp4' && t !== 'application/mp4') {
return false;
}
return true;
},
beforeUpload: function (file) {
if (this.uploading) {
this.$message.warning('正在上传,请稍候再试');
return false;
}
var isMP4 = file.type === 'video/mp4';
if (!isMP4) {
if (!this.isMp4File(file)) {
this.$message.error('只能上传 mp4 文件');
return false;
}
......@@ -105,6 +119,9 @@ new Vue({
if (!rawFile) {
return;
}
if (!this.isMp4File(file)) {
return;
}
if (this.videoPreviewUrl && this.videoPreviewUrl.indexOf('blob:') === 0) {
URL.revokeObjectURL(this.videoPreviewUrl);
}
......@@ -243,7 +260,7 @@ new Vue({
accessKeyId: ossConfig.accessKeyId,
accessKeySecret: ossConfig.accessKeySecret,
stsToken: ossConfig.securityToken,
bucket: 'iplayabc-worker-queue-video-mini',
bucket: 'iplayabc-worker-queue-videolmh',
cors: true,
secure: true,
silent: true
......@@ -267,15 +284,14 @@ new Vue({
if (ext !== 'mp4') {
return newFileName;
}
var miniName = md5 + '_mini.mp4';
return videoClient.multipartUpload(miniName, file, {
return videoClient.multipartUpload(newFileName, file, {
progress: function (p) {
if (uploadId === _this.currentUploadId) {
_this.uploadProgress = Math.floor(p * 50) + 50;
}
}
}).then(function () {
return miniName;
return newFileName;
});
});
}).then(function (fileName) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment