]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/attachment/FileAttachmentsStorage.java
Save current state even if not completely stable
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / attachment / FileAttachmentsStorage.java
index 4b4e13259dca12d3bdc8e358a7cc7e6edb12cb43..29d84111742fa1c5d5cf5af5285f3dbf5311fa80 100644 (file)
@@ -32,9 +32,10 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.Resource;
 
 public class FileAttachmentsStorage implements AttachmentsStorage,
-               InitializingBean {
+               AttachmentUploader, InitializingBean {
        private final static Log log = LogFactory
                        .getLog(FileAttachmentsStorage.class);
 
@@ -113,6 +114,14 @@ public class FileAttachmentsStorage implements AttachmentsStorage,
 
        }
 
+       public void upload(Attachment attachment, Resource resource) {
+               try {
+                       storeAttachment(attachment, resource.getInputStream());
+               } catch (IOException e) {
+                       throw new SlcException("Cannot upload attachment " + attachment, e);
+               }
+       }
+
        /** For monitoring purposes only */
        protected void updateAttachmentToc(Attachment attachment, File file) {
                Date date = new Date(file.lastModified());