|
|
@@ -116,9 +116,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getServerInfo } from '@/api/content'
|
|
|
import { videoRegion, addVideoPost } from '@/api/video'
|
|
|
import { getVideoChannelInfo, getVideoCoverChannelInfo } from '@/api/file'
|
|
|
+import { hashFile } from '@/utils/functions'
|
|
|
|
|
|
export default {
|
|
|
name: 'PublishVideo',
|
|
|
@@ -172,12 +172,25 @@ export default {
|
|
|
this.form.channelId = resData.channelId
|
|
|
this.options = {
|
|
|
target: resData.ossUrl,
|
|
|
- chunkSize: resData.maxSize,
|
|
|
+ // 分块大小 10MB
|
|
|
+ chunkSize: 1024 * 1024 * 10,
|
|
|
+ // 失败自动重传次数
|
|
|
+ maxChunkRetries: 3,
|
|
|
fileParameterName: 'file',
|
|
|
- testChunks: false,
|
|
|
+ testChunks: true,
|
|
|
+ // 服务器分片校验函数, 秒传及断点续传基础
|
|
|
+ checkChunkUploadedByResponse: function(chunk, message) {
|
|
|
+ const objMessage = JSON.parse(message)
|
|
|
+ const respData = objMessage.data
|
|
|
+ if (respData.skipUpload) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return (respData.uploaded || []).indexOf(chunk.offset + 1) >= 0
|
|
|
+ },
|
|
|
query: (file, chunk) => {
|
|
|
return {
|
|
|
- channelId: resData.channelId
|
|
|
+ channelId: resData.channelId,
|
|
|
+ multiparts: ''
|
|
|
}
|
|
|
},
|
|
|
headers: {
|
|
|
@@ -232,11 +245,11 @@ export default {
|
|
|
methods: {
|
|
|
// ****************************************************************************************************************
|
|
|
onFileAdded(file) {
|
|
|
- if (file.file.size > 1024 * 1024 * 1024 * 10) {
|
|
|
+ if (file.file.size > 1024 * 1024 * 1024 * 20) {
|
|
|
file.cancel()
|
|
|
this.$notify({
|
|
|
title: '提示',
|
|
|
- message: '视频文件应小于 10GB',
|
|
|
+ message: '文件应小于 20GB',
|
|
|
type: 'warning',
|
|
|
duration: 3000
|
|
|
})
|
|
|
@@ -244,6 +257,15 @@ export default {
|
|
|
}
|
|
|
this.setTitle(file.file.name)
|
|
|
this.processVideo(file.file)
|
|
|
+
|
|
|
+ file.pause()
|
|
|
+ hashFile(file.file).then(result => {
|
|
|
+ this.startUpload(result.sha256sum, file)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ startUpload(sha256sum, file) {
|
|
|
+ file.uniqueIdentifier = sha256sum
|
|
|
+ file.resume()
|
|
|
},
|
|
|
onFileProgress(rootFile, file, chunk) {
|
|
|
},
|