Examples of ERFileAttachment


Examples of er.attachment.model.ERFileAttachment

    }
    else if (!webPath.startsWith("/")) {
      webPath = "/" + webPath;
    }

    ERFileAttachment attachment = ERFileAttachment.createERFileAttachment(editingContext, Boolean.TRUE, new NSTimestamp(), mimeType, recommendedFileName, Boolean.valueOf(proxy), Integer.valueOf((int) uploadedFile.length()), webPath);
    if (delegate() != null) {
      delegate().attachmentCreated(this, attachment);
    }
    try {
      webPath = ERAttachmentProcessor._parsePathTemplate(attachment, webPath, recommendedFileName);
      filesystemPath = ERAttachmentProcessor._parsePathTemplate(attachment, filesystemPath, recommendedFileName);

      File desiredFilesystemPath = new File(filesystemPath);
      File actualFilesystemPath = ERXFileUtilities.reserveUniqueFile(desiredFilesystemPath, overwrite);

      ERXFileUtilities.copyFileToFile(uploadedFile, actualFilesystemPath, pendingDelete, true);

      String desiredFileName = desiredFilesystemPath.getName();
      String actualFileName = actualFilesystemPath.getName();
      // in case the name was not unique and changed, we need to update webPath ...
      webPath = webPath.replaceAll("\\Q" + desiredFileName + "\\E$", actualFileName);

      attachment.setWebPath(webPath);
      attachment.setFilesystemPath(actualFilesystemPath.getAbsolutePath());

      if (delegate() != null) {
        delegate().attachmentAvailable(this, attachment);
      }
    }
    catch (IOException e) {
      attachment.delete();
      throw e;
    }
    catch (RuntimeException e) {
      attachment.delete();
      throw e;
    }

    return attachment;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.