aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/file-upload.js
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-03-09 13:55:57 +0100
committerGitHub <noreply@github.com>2023-03-09 13:55:57 +0100
commit315510df8464a97656f614b6b4ba15a3fb11d337 (patch)
tree1e1c0513c82c6401b03937e55578b9982ea91189 /apps/files/js/file-upload.js
parent691aa8d0257e9361bbc5a64b09cd634435dbd40a (diff)
parentd2a05716753cc9297fa38e88a43e39dec71f3b40 (diff)
downloadnextcloud-server-315510df8464a97656f614b6b4ba15a3fb11d337.tar.gz
nextcloud-server-315510df8464a97656f614b6b4ba15a3fb11d337.zip
Merge pull request #27034 from nextcloud/enh/s3-multipart-upload-api
Use MultipartUpload for uploading chunks to s3
Diffstat (limited to 'apps/files/js/file-upload.js')
-rw-r--r--apps/files/js/file-upload.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 7d6bde6e0f9..f3a39e5861a 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -269,8 +269,12 @@ OC.FileUpload.prototype = {
&& this.getFile().size > this.uploader.fileUploadParam.maxChunkSize
) {
data.isChunked = true;
+ var headers = {
+ Destination: this.uploader.davClient._buildUrl(this.getTargetDestination())
+ };
+
chunkFolderPromise = this.uploader.davClient.createDirectory(
- 'uploads/' + OC.getCurrentUser().uid + '/' + this.getId()
+ 'uploads/' + OC.getCurrentUser().uid + '/' + this.getId(), headers
);
// TODO: if fails, it means same id already existed, need to retry
} else {
@@ -309,17 +313,22 @@ OC.FileUpload.prototype = {
}
if (size) {
headers['OC-Total-Length'] = size;
-
}
+ headers['Destination'] = this.uploader.davClient._buildUrl(this.getTargetDestination());
return this.uploader.davClient.move(
'uploads/' + uid + '/' + this.getId() + '/.file',
- 'files/' + uid + '/' + OC.joinPaths(this.getFullPath(), this.getFileName()),
+ this.getTargetDestination(),
true,
headers
);
},
+ getTargetDestination: function() {
+ var uid = OC.getCurrentUser().uid;
+ return 'files/' + uid + '/' + OC.joinPaths(this.getFullPath(), this.getFileName());
+ },
+
_deleteChunkFolder: function() {
// delete transfer directory for this upload
this.uploader.davClient.remove(
@@ -1326,6 +1335,10 @@ OC.Uploader.prototype = _.extend({
}
var range = data.contentRange.split(' ')[1];
var chunkId = range.split('/')[0].split('-')[0];
+ // Use a numeric chunk id and set the Destination header on all request for ChunkingV2
+ chunkId = Math.ceil((data.chunkSize+Number(chunkId)) / upload.uploader.fileUploadParam.maxChunkSize);
+ data.headers['Destination'] = self.davClient._buildUrl(upload.getTargetDestination());
+
data.url = OC.getRootPath() +
'/remote.php/dav/uploads' +
'/' + OC.getCurrentUser().uid +