Commit cacd490f by Jan Hrabal

attachments

parent 63ff79bc
...@@ -229,7 +229,7 @@ CREATE INDEX LEGAL_DOCUMENT_IDX ON LEGAL_DOCUMENT(CODE, LOCALE); ...@@ -229,7 +229,7 @@ CREATE INDEX LEGAL_DOCUMENT_IDX ON LEGAL_DOCUMENT(CODE, LOCALE);
-- ATTACHMENTS -- ATTACHMENTS
CREATE TABLE ATTACHMENT ( CREATE TABLE ATTACHMENT (
ID INT8 NOT NULL, ID INT8 NOT NULL,
UNIT_ID INT8 NOT NULL, UNIT_ID INT8,
OBJECT_TYPE VARCHAR(128), OBJECT_TYPE VARCHAR(128),
OBJECT_ID INT8, OBJECT_ID INT8,
......
...@@ -36,7 +36,9 @@ public class FileBasedAttachmentService extends AbstractHibernateAttachmentServi ...@@ -36,7 +36,9 @@ public class FileBasedAttachmentService extends AbstractHibernateAttachmentServi
protected File file(Attachment attachment) { protected File file(Attachment attachment) {
Objects.requireNonNull(attachment, "Attachment must not be null"); Objects.requireNonNull(attachment, "Attachment must not be null");
return Paths.get(dataDirectory, s(attachment.getUnitId()), attachment.getObjectType(), s(attachment.getObjectId()), attachment.getFilename()).toFile(); File file = Paths.get(dataDirectory, s(attachment.getUnitId()), attachment.getObjectType(), s(attachment.getObjectId()), attachment.getFilename()).toFile();
file.getParentFile().mkdirs();
return file;
} }
...@@ -44,7 +46,7 @@ public class FileBasedAttachmentService extends AbstractHibernateAttachmentServi ...@@ -44,7 +46,7 @@ public class FileBasedAttachmentService extends AbstractHibernateAttachmentServi
return n == null ? "0" : String.valueOf(n); return n == null ? "0" : String.valueOf(n);
} }
@Value("${attachment.dataDir:/app/data}") @Value("${attachment.store.path:/var/data}")
public void setDataDirectory(String dataDirectory) { public void setDataDirectory(String dataDirectory) {
this.dataDirectory = dataDirectory; this.dataDirectory = dataDirectory;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment