From ea88ad99af25eb8cb209ec3eaf663e49edf47e73 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Tue, 27 Sep 2016 13:46:47 +0000 Subject: [PATCH] SHA-1698 - Enhancement to V0 Upload API to support creation of folder path during upload process. Added to Script API and Test suite. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@130934 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/repository/upload/upload.post.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js b/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js index bf026321c0..8f7f6a59a8 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js @@ -16,6 +16,7 @@ function exitUpload(statusCode, statusMsg) status.message = statusMsg; status.redirect = true; } + /** * Creates an new filename by adding a suffix to existing one in order to avoid duplicates in folder * The check that folder already contains the filename should be done before calling this function @@ -69,6 +70,7 @@ function main() // Upload specific var uploadDirectory = null, + createDirectory = false, contentType = null, aspects = [], overwrite = true; // If a filename clashes for a versionable file @@ -173,10 +175,14 @@ function main() case "updatenameandmimetype": updateNameAndMimetype = field.value == "true"; break; + + case "createdirectory": + createDirectory = field.value == "true"; + break; } } - //MNT-7213 When alf_data runs out of disk space, Share uploads result in a success message, but the files do not appear + // MNT-7213 When alf_data runs out of disk space, Share uploads result in a success message, but the files do not appear if (formdata.fields.length == 0) { exitUpload(404, " No disk space available"); @@ -336,8 +342,15 @@ function main() var child = destNode.childByNamePath(uploadDirectory); if (child === null) { - exitUpload(404, "Cannot upload file since upload directory '" + uploadDirectory + "' does not exist."); - return; + if (createDirectory) + { + child = destNode.createFolderPath(uploadDirectory); + } + else + { + exitUpload(404, "Cannot upload file since upload directory '" + uploadDirectory + "' does not exist."); + return; + } } // MNT-12565