Examples of ServletFileUpload


Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

      throw new IllegalStateException(
        "ServletRequest does not contain multipart content. One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to auto-detect multipart forms but there are certain situation where it cannot.");
    }

    // Configure the factory here, if desired.
    ServletFileUpload fileUpload = new ServletFileUpload(factory);

    // The encoding that will be used to decode the string parameters
    // It should NOT be null at this point, but it may be
    // especially if the older Servlet API 2.2 is used
    String encoding = request.getCharacterEncoding();

    // The encoding can also be null when using multipart/form-data encoded forms.
    // In that case we use the [application-encoding] which we always demand using
    // the attribute 'accept-encoding' in wicket forms.
    if (encoding == null)
    {
      encoding = Application.get().getRequestCycleSettings().getResponseRequestEncoding();
    }

    // set encoding specifically when we found it
    if (encoding != null)
    {
      fileUpload.setHeaderEncoding(encoding);
    }

    fileUpload.setSizeMax(maxSize.bytes());

    final List<FileItem> items;

    if (wantUploadProgressUpdates())
    {
      ServletRequestContext ctx = new ServletRequestContext(request)
      {
        @Override
        public InputStream getInputStream() throws IOException
        {
          return new CountingInputStream(super.getInputStream());
        }
      };
      totalBytes = request.getContentLength();

      onUploadStarted(totalBytes);
      try
      {
        items = fileUpload.parseRequest(ctx);
      }
      finally
      {
        onUploadCompleted();
      }
    }
    else
    {
      items = fileUpload.parseRequest(request);
    }

    // Loop through items
    for (final FileItem item : items)
    {
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

    DiskFileItemFactory factory = new DiskFileItemFactory();

    //
    // Create a new file upload handler
    //
    ServletFileUpload upload = new ServletFileUpload(factory);

    //
    // maximum size before a FileUploadException will be thrown
    //
    upload.setSizeMax(1024 * 1024 * 1024);

    //
    // process upload request
    //
    @SuppressWarnings("unchecked")
    List<FileItem> fileItems = upload.parseRequest(request);

    _logger.debug(serverPath);

    //
    // Only save .wgt files and ignore any others in the POST
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

        boolean isMultipart = ServletFileUpload.isMultipartContent(request);
        if (isMultipart) {

            // Streaming API typically provide better performance for file uploads.
            // Create a new file upload handler
            ServletFileUpload upload = new ServletFileUpload();

            try {
                // Now we should have the componentsName and upload directory to setup remaining upload of file items
                String compName = htUpload.get(FileUploadUtil.COMPONENT_NAME);
                status.setName(compName);

                // Parse the request and return list of "FileItem" whle updating status
                FileItemIterator iter = upload.getItemIterator(request);

                status.setReadingComplete();

                while (iter.hasNext()) {
                    item = iter.next();
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

            rd.forward(request, response);
            return;
        }
        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload();

        // Parse the request
        try {
            FileItemIterator iter = upload.getItemIterator(request);
            while (iter.hasNext() == true) {
                FileItemStream item = iter.next();
                InputStream stream = item.openStream();
                if (item.isFormField() == false) {
                    /*
 
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

    String phoneNumber = null;
    String defaultCountry = null;
    String languageCode = "en"// Default languageCode to English if nothing is entered.
    String regionCode = "";
    String fileContents = null;
    ServletFileUpload upload = new ServletFileUpload();
    upload.setSizeMax(50000);
    try {
      FileItemIterator iterator = upload.getItemIterator(req);
      while (iterator.hasNext()) {
        FileItemStream item = iterator.next();
        InputStream in = item.openStream();
        if (item.isFormField()) {
          String fieldName = item.getFieldName();
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

String dfo = null;
String enc = null;
if (isMultipart){
 
 
  ServletFileUpload upload = new ServletFileUpload();

upload.setSizeMax(mU);
try {
    FileItemIterator iter = upload.getItemIterator(req);
//List<FileItem> items = upload.parseRequest(req);

while (iter.hasNext()) {
       FileItemStream item = iter.next();
//for (int ct = 0;ct < items.size();ct++){
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

   */
  public void parse(HttpServletRequest request) throws IOException {

    // Parse the request
    try {
      ServletFileUpload upload = new ServletFileUpload();
      upload.setSizeMax(maxSize);

      FileItemIterator iterator = upload.getItemIterator(request);

      while (iterator.hasNext()) {
        FileItemStream itemStream = iterator.next();
        InputStream in = itemStream.openStream();

View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

            // Create a factory for disk-based file items
            FileItemFactory factory = new DiskFileItemFactory();

            // Create a new file upload handler
            ServletFileUpload upload = new ServletFileUpload(factory);

            // Parse the request
            try {
                resp.setContentType("text/plain");
                FileItemIterator iterator = upload.getItemIterator(req);

                while (iterator.hasNext()) {
                    FileItemStream item = iterator.next();
                   InputStream stream = item.openStream();
                  if (item.isFormField()) {
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

        HttpSession session = request.getSession(true);
        GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
       
        Map<String, String> formInput = FastMap.newInstance();
        ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, FileUtil.getFile("runtime/tmp")));
        List<FileItem> lst = null;
        try {
           lst = UtilGenerics.checkList(fu.parseRequest(request));
        } catch (FileUploadException e4) {
            return e4.getMessage();
        }
               
        FileItem fi = null;
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

            LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
            Delegator delegator = (Delegator) request.getAttribute("delegator");
            HttpSession session = request.getSession();
            GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");

            ServletFileUpload dfu = new ServletFileUpload(new DiskFileItemFactory(10240, FileUtil.getFile("runtime/tmp")));
            List<FileItem> lst = null;
            try {
                lst = UtilGenerics.checkList(dfu.parseRequest(request));
            } catch (FileUploadException e4) {
                request.setAttribute("_ERROR_MESSAGE_", e4.getMessage());
                Debug.logError("[UploadContentAndImage.uploadContentAndImage] " + e4.getMessage(), module);
                return "error";
            }
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.