Examples of FileUpload


Examples of jodd.upload.FileUpload

*/
public class FileUploadToFileTypeConverter implements TypeConverter<File> {

  public File convert(Object value) {
    if (value instanceof FileUpload) {
      FileUpload fileUpload = (FileUpload) value;

      InputStream in = null;
      try {
        in = fileUpload.getFileInputStream();

        File tempFile = FileUtil.createTempFile();

        FileUtil.writeStream(tempFile, in);

View Full Code Here

Examples of net.sourceforge.jwbf.mediawiki.actions.editing.FileUpload

      ProcessException {

    File f = new File(fileName);

    SimpleFile a = new SimpleFile(f.getName(), fileName);
    performAction(new FileUpload(a, this));
   
   

  }
View Full Code Here

Examples of org.apache.commons.fileupload.FileUpload

        if (!MemoryControl.request(request.getContentLength() * 3, false)) {
          throw new IOException("not enough memory available for request. request.getContentLength() = " + request.getContentLength() + ", MemoryControl.available() = " + MemoryControl.available());
        }

        // parse data in memory
        final FileUpload upload = new FileUpload(DISK_FILE_ITEM_FACTORY);
        final List<FileItem> items;

        try {
            items = upload.parseRequest(request);
        } catch (FileUploadException e) {
            throw new IOException("FileUploadException " + e.getMessage());
        }

        // format information for further usage
View Full Code Here

Examples of org.apache.commons.fileupload.FileUpload

               ? RequestHandler.WS_RS_BUFFER_SIZE_VALUE : Integer.parseInt(context.getProperties().get(
                  RequestHandler.WS_RS_BUFFER_SIZE));
         File repo = new File(context.getProperties().get(RequestHandler.WS_RS_TMP_DIR));

         DefaultFileItemFactory factory = new DefaultFileItemFactory(bufferSize, repo);
         final FileUpload upload = new FileUpload(factory);

         return SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Iterator<FileItem>>()
         {
            public Iterator<FileItem> run() throws Exception
            {
               return upload.parseRequest(httpRequest).iterator();
            }
         });
      }
      catch (PrivilegedActionException pae)
      {
View Full Code Here

Examples of org.apache.commons.fileupload.FileUpload

  public MultipartFormData readFrom(Class<MultipartFormData> type, Type genericType, Annotation[] annotations, MediaType mediaType,
      MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {

    final MultipartFormData multipartFormData = createMultipartFormDataInstance();
    final FileUpload fileUpload = createFileUploadInstance();

    String contentType = httpHeaders.getFirst("content-type");
    RestMultipartRequestContext requestContext = createRequestContext(entityStream, contentType);

    // parse the request (populates the multipartFormData)
View Full Code Here

Examples of org.apache.commons.fileupload.FileUpload

    return multipartFormData;

  }

  protected FileUpload createFileUploadInstance() {
    return new FileUpload();
  }
View Full Code Here

Examples of org.apache.commons.fileupload.FileUpload

      try
      {
         if (FileUpload.isMultipartContent(requestContext))
         {
            // content is multipart, we need to parse it (that includes form parameters)
            FileUpload upload = new FileUpload();
            FileItemIterator iter = upload.getItemIterator(requestContext);
            List<UploadContext> uploadContexts = new ArrayList<UploadContext>(7);
            List<NamedString> formParameters = new ArrayList<NamedString>(7);
            while (iter.hasNext())
            {
               FileItemStream item = iter.next();
View Full Code Here

Examples of org.apache.commons.fileupload.FileUpload

   * @return the parsing result
   * @throws MultipartException if multipart resolution failed.
   */
  protected MultipartParsingResult parseRequest(HttpServletRequest request) throws MultipartException {
    String encoding = determineEncoding(request);
    FileUpload fileUpload = prepareFileUpload(encoding);
    try {
      List fileItems = ((ServletFileUpload) fileUpload).parseRequest(request);
      return parseFileItems(fileItems, encoding);
    }
    catch (FileUploadBase.SizeLimitExceededException ex) {
      throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
    }
    catch (FileUploadException ex) {
      throw new MultipartException("Could not parse multipart servlet request", ex);
    }
  }
View Full Code Here

Examples of org.apache.commons.fileupload.FileUpload

   * with the same configuration other than the desired encoding.
   * @param encoding the character encoding to use
   * @return an appropriate FileUpload instance.
   */
  protected FileUpload prepareFileUpload(String encoding) {
    FileUpload fileUpload = getFileUpload();
    FileUpload actualFileUpload = fileUpload;

    // Use new temporary FileUpload instance if the request specifies
    // its own encoding that does not match the default encoding.
    if (encoding != null && !encoding.equals(fileUpload.getHeaderEncoding())) {
      actualFileUpload = newFileUpload(getFileItemFactory());
      actualFileUpload.setSizeMax(fileUpload.getSizeMax());
      actualFileUpload.setHeaderEncoding(encoding);
    }

    return actualFileUpload;
  }
View Full Code Here

Examples of org.apache.commons.fileupload.FileUpload

    @SuppressWarnings("unchecked")
    public List<FileItem> readFrom(Class<List<FileItem>> type,
            Type genericType, Annotation[] annotations, MediaType mediaType,
            final MultivaluedMap<String, String> respHeaders,
            final InputStream entityStream) throws IOException {
        final FileUpload rfu = new FileUpload();
        final RequestContext requCtx = new RequestContext(entityStream,
                respHeaders);
        try {
            return rfu.parseRequest(requCtx);
        } catch (FileUploadException e) {
            if (e.getCause() instanceof IOException) {
                throw (IOException) e.getCause();
            }
            final IOException ioExc = new IOException(
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.