summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-08-27 15:28:26 +0200
committerThomas Citharel <tcit@tcit.fr>2017-09-15 16:53:10 +0200
commit246a5a5750dd2b8f990797b2c6cc4270a9a5b59d (patch)
tree5fd3e6bdfe70f6d1afdcd2bd2f9ed0f2c5a3c03d /core/js
parent8500e114575d7e02ffda8070980cc77ba147e60f (diff)
downloadnextcloud-server-246a5a5750dd2b8f990797b2c6cc4270a9a5b59d.tar.gz
nextcloud-server-246a5a5750dd2b8f990797b2c6cc4270a9a5b59d.zip
Allow files to be copied through action menu & multiple files actions
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'core/js')
-rw-r--r--core/js/files/client.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/core/js/files/client.js b/core/js/files/client.js
index 176cabf04b1..dc9f6ade641 100644
--- a/core/js/files/client.js
+++ b/core/js/files/client.js
@@ -737,6 +737,51 @@
},
/**
+ * Copies path to another path
+ *
+ * @param {String} path path to copy
+ * @param {String} destinationPath destination path
+ * @param {boolean} [allowOverwrite=false] true to allow overwriting,
+ * false otherwise
+ *
+ * @return {Promise} promise
+ */
+ copy: function (path, destinationPath, allowOverwrite) {
+ if (!path) {
+ throw 'Missing argument "path"';
+ }
+ if (!destinationPath) {
+ throw 'Missing argument "destinationPath"';
+ }
+
+ var self = this;
+ var deferred = $.Deferred();
+ var promise = deferred.promise();
+ var headers = {
+ 'Destination' : this._buildUrl(destinationPath)
+ };
+
+ if (!allowOverwrite) {
+ headers.Overwrite = 'F';
+ }
+
+ this._client.request(
+ 'COPY',
+ this._buildUrl(path),
+ headers
+ ).then(
+ function(response) {
+ if (self._isSuccessStatus(response.status)) {
+ deferred.resolve(response.status);
+ } else {
+ deferred.reject(response.status);
+ }
+ }
+ );
+ return promise;
+ },
+
+ /**
* Add a file info parser function
*
* @param {OC.Files.Client~parseFileInfo>}