aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/services/Templates.js
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2021-09-17 09:52:02 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2021-09-17 10:08:32 +0200
commited8aacf415d89859a1cf0b53189bc1a7b4de72bc (patch)
treee2fa7f8de68f4422982d579e09501a15b7912d7a /apps/files/src/services/Templates.js
parent62a814f4fbdec485e97e6b55a8320a02ced488bb (diff)
downloadnextcloud-server-ed8aacf415d89859a1cf0b53189bc1a7b4de72bc.tar.gz
nextcloud-server-ed8aacf415d89859a1cf0b53189bc1a7b4de72bc.zip
Fix file creation from template without ext
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/src/services/Templates.js')
-rw-r--r--apps/files/src/services/Templates.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/files/src/services/Templates.js b/apps/files/src/services/Templates.js
index f92747b7282..b466def408f 100644
--- a/apps/files/src/services/Templates.js
+++ b/apps/files/src/services/Templates.js
@@ -27,3 +27,19 @@ export const getTemplates = async function() {
const response = await axios.get(generateOcsUrl('apps/files/api/v1/templates'))
return response.data.ocs.data
}
+
+/**
+ * Create a new file from a specified template
+ *
+ * @param {string} filePath The new file destination path
+ * @param {string} templatePath The template source path
+ * @param {string} templateType The template type e.g 'user'
+ */
+export const createFromTemplate = async function(filePath, templatePath, templateType) {
+ const response = await axios.post(generateOcsUrl('apps/files/api/v1/templates/create'), {
+ filePath,
+ templatePath,
+ templateType,
+ })
+ return response.data.ocs.data
+}