Examples of Uploadable


Examples of jodd.http.up.Uploadable

          buffer.append("Content-Disposition: form-data; name=\"").append(name).append('"').append(CRLF);
          buffer.append(CRLF);
          buffer.append(string);
        }
        else if (value instanceof Uploadable) {
          Uploadable uploadable = (Uploadable) value;

          String fileName = uploadable.getFileName();
          if (fileName == null) {
            fileName = name;
          }

          buffer.append("Content-Disposition: form-data; name=\"").append(name);
          buffer.append("\"; filename=\"").append(fileName).append('"').append(CRLF);

          String mimeType = uploadable.getMimeType();
          if (mimeType == null) {
            mimeType = MimeTypes.getMimeType(FileNameUtil.getExtension(fileName));
          }
          buffer.append(HEADER_CONTENT_TYPE).append(": ").append(mimeType).append(CRLF);
View Full Code Here

Examples of jodd.http.up.Uploadable

        byte[] array = fastByteBuffer.toArray();

        writer.write(new String(array, StringPool.ISO_8859_1));
      }
      else if (o instanceof Uploadable) {
        Uploadable uploadable = (Uploadable) o;

        InputStream inputStream = uploadable.openInputStream();

        try {
          StreamUtil.copy(inputStream, writer, StringPool.ISO_8859_1);
        }
        finally {
View Full Code Here

Examples of jodd.http.up.Uploadable

        FastByteBuffer fastByteBuffer = (FastByteBuffer) o;

        out.write(fastByteBuffer.toArray());
      }
      else if (o instanceof Uploadable) {
        Uploadable uploadable = (Uploadable) o;

        InputStream inputStream = uploadable.openInputStream();

        try {
          StreamUtil.copy(inputStream, out);
        }
        finally {
View Full Code Here

Examples of jodd.http.up.Uploadable

            step -= callbackSize;
          }
        }
      }
      else if (o instanceof Uploadable) {
        Uploadable uploadable = (Uploadable) o;

        InputStream inputStream = uploadable.openInputStream();

        int remaining = uploadable.getSize();

        try {
          while (remaining > 0) {
            // calc the remaining sending chunk size
            int chunk = callbackSize - step;
View Full Code Here

Examples of org.opentides.bean.Uploadable

    // are we expecting file upload?
    if (Uploadable.class.isAssignableFrom(command.getClass())
        && request instanceof MultipartHttpServletRequest) {
      List<FileInfo> files = null;
      Uploadable upload = (Uploadable) command;
      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
      List<MultipartFile> multipartFiles = multipartRequest
          .getFiles(htmlId);

      // check if there is anything to process
      if (multipartFiles != null && !multipartFiles.isEmpty())
        // loop through all the attachments
        for (MultipartFile multipartFile : multipartFiles) {
          // check if there is anything to process
          if (multipartFile != null && !multipartFile.isEmpty()) {
            FileInfo fileInfo = new FileInfo();
            fileInfo.setFilename(multipartFile.getOriginalFilename());
            fileInfo.setFileSize(multipartFile.getSize());
            fileInfo.setFullPath(uploadPath);

            try {
              // setup the directory
              File directory;
              directory = FileUtil.createDirectory(uploadPath);
              String subdir = directory.getAbsoluteFile()
                  + File.separator
                  + DateUtil.convertShortDate(new Date());
              File subDirectory = FileUtil.createDirectory(subdir);

              String filePath = subDirectory.getAbsoluteFile()
                  + File.separator
                  + multipartFile.getOriginalFilename();

              // change filename if already existing in the given path
              // to avoid overriding of files
              if (fileInfoService.getFileInfoByFullPath(filePath) != null) {
                Long fileCnt = 1L;
                String newFilePath = subDirectory.getAbsoluteFile()
                    + File.separator + fileCnt.toString() + "_"
                    + multipartFile.getOriginalFilename();
                while (fileInfoService
                    .getFileInfoByFullPath(newFilePath) != null) {
                  fileCnt++;
                  newFilePath = subDirectory.getAbsoluteFile()
                      + File.separator + fileCnt.toString()
                      + "_"
                      + multipartFile.getOriginalFilename();
                }

                filePath = newFilePath;
                fileInfo.setOriginalFileName(multipartFile
                    .getOriginalFilename());
              }

              File uploadFile = new File(filePath);

              // update file path information
              fileInfo.setFullPath(uploadFile.getAbsolutePath());
              _log.debug("Uploading file to "
                  + fileInfo.getFullPath());
              // now copy the file
              FileUtil.copyMultipartFile(multipartFile, uploadFile);
              // add fileinfo
              if (isMultipleUpload())
                files = upload.getFiles();
              if (files == null)
                files = new ArrayList<FileInfo>();
              files.add(fileInfo);
              upload.setFiles(files);

            } catch (IOException e) {
              _log.error("Failed to upload file.", e);
              throw e;
            }
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.