Skip to content

Commit

Permalink
Add TUS capability detection and fix upload
Browse files Browse the repository at this point in the history
Read TUS capability from the file info returned by the SDK.
Fix chunked upload by removing the file name from the path.
  • Loading branch information
Vincent Petry committed Apr 22, 2020
1 parent a144afb commit f562697
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions apps/files/src/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default {
'highlightedFile',
'publicLinkPassword',
'fileSortField',
'currentFolder',
'fileSortDirectionDesc'
]),
...mapGetters(['getToken', 'capabilities']),
Expand Down Expand Up @@ -408,11 +409,11 @@ export default {
} else {
basePath = this.path || ''
relativePath = pathUtil.join(basePath, relativePath)
const isChunkedSupported = true

if (isChunkedSupported) {
// FIXME: this might break if relativePath is not the currentFolder
// and is a mount point that has no chunk support
if (this.browserSupportsChunked && this.currentFolder.isChunkedUploadSupported) {
promise = this.uploadQueue.add(() => {
return this.uploadChunkedFile(file, relativePath, {
return this.uploadChunkedFile(file, pathUtil.dirname(relativePath), {
emitProgress: progress => {
this.$_ocUpload_onProgress(progress, file)
}
Expand Down
3 changes: 2 additions & 1 deletion apps/files/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ function _buildFile(file) {
},
isReceivedShare: function() {
return this.permissions.indexOf('S') >= 0
}
},
isChunkedUploadSupported: !!(file.getTusSupport && file.getTusSupport())
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/plugins/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import tus from 'tus-js-client'
export default {
install(Vue) {
Vue.mixin({
computed: {
browserSupportsChunked() {
return tus.isSupported
}
},
methods: {
uploadChunkedFile(file, path, options) {
// TODO: proper handling of directory uploads which have a path prefix
Expand Down

0 comments on commit f562697

Please sign in to comment.