Package com.oreilly.servlet.multipart

Examples of com.oreilly.servlet.multipart.FileRenamePolicy


        }
      } else {
        // file already exists... upload anyway with new filename and
        // in the folder manager status.
        // rename file and ask user what to do
        FileRenamePolicy frp = new DefaultFileRenamePolicy();
        if ( ! (existingVFSItem instanceof LocalImpl)) {
          throw new AssertException("Can only LocalImpl VFS items, don't know what to do with file of type::" + existingVFSItem.getClass().getCanonicalName());
        }
        File existingFile = ((LocalImpl)existingVFSItem).getBasefile();
        File tmpOrigFilename = new File(existingFile.getAbsolutePath());
        String renamedFilename = frp.rename(tmpOrigFilename).getName();
        newFile = (VFSLeaf) uploadVFSContainer.resolve(renamedFilename);
        // Copy content to tmp file
        BufferedInputStream in = new BufferedInputStream(fileEl.getUploadInputStream());
        BufferedOutputStream out = new BufferedOutputStream(newFile.getOutputStream(false));
        boolean success = false;
View Full Code Here


      destinationDir.mkdirs();
      // Check if such a file does already exist, if yes rename new file
      File existsFile = new File(destinationDir, uploadFilename);
      if (existsFile.exists()) {
        // Use standard rename policy
        FileRenamePolicy frp = new DefaultFileRenamePolicy();
        File tmpF = new File(uploadFilename);
        uploadFilename = frp.rename(tmpF).getName();
      }
      // Move file now
      File targetFile = new File(destinationDir, uploadFilename);
      if (FileUtils.copyFileToFile(tempUploadFile, targetFile, true)) { return targetFile; }
    }
View Full Code Here

    public void build(HttpServletRequest request, final File tempDir, long maxPostSize)
            throws IOException, FileUploadLimitExceededException {

        try {
            // Create a new file in the temp directory in case of file name conflict
            FileRenamePolicy renamePolicy = new FileRenamePolicy() {
                public File rename(File arg0) {
                    try {
                        return File.createTempFile("cos", "", tempDir);
                    }
                    catch (IOException e) {
View Full Code Here

TOP

Related Classes of com.oreilly.servlet.multipart.FileRenamePolicy

Copyright © 2018 www.massapicom. 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.