Skip to content

Commit

Permalink
Added ability to pass location on attachment creation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyzvegintcev committed May 9, 2019
1 parent dcdf6d1 commit 1b0cc1d
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ class AppResourceLoader implements ResourceLoader, GrailsConfigurationAware {
* file: the File instace that we put in that directory
*/
@SuppressWarnings("ReturnsNullInsteadOfEmptyCollection")
Map createAttachmentFile(Long attachmentId, String name, String extension, Object data) {
Map createAttachmentFile(Long attachmentId, String name, String extension, Object data, String location = null) {
if (!data) return null
if(!location) location = ATTACHMENT_LOCATION_KEY
String prefix = ""
if (name) {
prefix = "${name}_"
Expand All @@ -139,7 +140,7 @@ class AppResourceLoader implements ResourceLoader, GrailsConfigurationAware {
String destFileName = extension ? "${prefix}${attachmentId}.${extension}" : "${prefix}${attachmentId}"

//setup the monthly dir for attachments
File monthDir = getMonthDirectory(ATTACHMENT_LOCATION_KEY)
File monthDir = getMonthDirectory(location)
File file = new File(monthDir, destFileName)
if (data) {
if (data instanceof File) FileUtils.moveFile(data, file)
Expand Down

0 comments on commit 1b0cc1d

Please sign in to comment.