Package com.oreilly.servlet.multipart

Examples of com.oreilly.servlet.multipart.MultipartParser


    savedir = saveDirectory;

    // Parse the incoming multipart, storing files in the dir provided,
    // and populate the meta objects which describe what we found
    MultipartParser parser = new MultipartParser(request, maxPostSize, true, true, encoding);

    // Some people like to fetch query string parameters from
    // MultipartRequest, so here we make that possible.  Thanks to
    // Ben Johnson, ben.johnson@merrillcorp.com, for the idea.
    if (request.getQueryString() != null) {
      // Let HttpUtils create a name->String[] structure
      Hashtable queryParameters =
        HttpUtils.parseQueryString(request.getQueryString());
      // For our own use, name it a name->Vector structure
      Enumeration queryParameterNames = queryParameters.keys();
      while (queryParameterNames.hasMoreElements()) {
        Object paramName = queryParameterNames.nextElement();
        String[] values = (String[])queryParameters.get(paramName);
        Vector newValues = new Vector();
        for (int i = 0; i < values.length; i++) {
          newValues.add(values[i]);
        }
        parameters.put(paramName, newValues);
      }
    }

    Part part;
    while ((part = parser.readNextPart()) != null) {
      String name = part.getName();
      if (part.isParam()) {
        // It's a parameter part, add it to the vector of values
        ParamPart paramPart = (ParamPart) part;
        String value = paramPart.getStringValue();
View Full Code Here


            if (req.getContentType() != null
                    && req.getContentType().toUpperCase().
                    startsWith("MULTIPART/FORM-DATA")) {
                final int size = Integer.parseInt(WebMailServer.
                        getStorage().getConfig("max attach size"));
                final MultipartParser mparser = new MultipartParser(req, size);
                Part p;
                while ((p = mparser.readNextPart()) != null) {
                    if (p.isFile()) {
                        final ByteStore bs = ByteStore.getBinaryFromIS(
                                ((FilePart) p).getInputStream(), size);
                        bs.setName(((FilePart) p).getFileName());
                        bs.setContentType(getStorage().getMimeType(
View Full Code Here

  private void processCalendarFileUpload(UserRequest ureq) {
    // upload the file
    try {
      // don't worry about NullPointerExceptions.
      // we'll catch exceptions if any operation fails.
      MultipartParser mpp = new MultipartParser(ureq.getHttpReq(), (int) fileUploadLimit * 1024);
      mpp.setEncoding("UTF-8");
      Part part;
      boolean fileWritten = false;
      while ((part = mpp.readNextPart()) != null) {
        if (part.isFile() && !fileWritten) {
          FilePart fPart = (FilePart) part;
          String type = fPart.getContentType();
          // get file contents
          Tracing.logWarn(type + fPart.getFileName(), this.getClass());
View Full Code Here

            // parse request body
            String contentType = source.getContentType();
            if (contentType != null && contentType.startsWith("multipart/form-data") && !isPortletRequest) {
                com.oreilly.servlet.multipart.Part attachmentPart;
                try {
                    MultipartParser multi = new MultipartParser(source, source.getContentLength(), true, true, "UTF-8");
                    boolean noAttachments = source.getContentLength() > sizeLimit;
                   
                    while ((attachmentPart = multi.readNextPart()) != null) {
                        String partName = attachmentPart.getName();

                        if (attachmentPart.isParam()) {
                            ParamPart parameterPart = (ParamPart)attachmentPart;
                            String paramValue = parameterPart.getStringValue();
View Full Code Here

    // case user not use httpclient MultPart Method upload file, but use url
    // and query
    // parameters( /ul?fcontent=xxx)
    try {
      // Max file size = 1GB
      MultipartParser mp = new MultipartParser(request,
          1024 * 1024 * 1024, false, false, "gbk");
      System.out
          .println("The file is uploaded by httpclient multiple part method.");
      Part part;
      while ((part = mp.readNextPart()) != null) {
        String name = part.getName();
        if (part.isParam()) {
          ParamPart paramPart = (ParamPart) part;
          String value = paramPart.getStringValue();
          // System.out.println("param: name=" + name + "; value=" +
View Full Code Here

     * @throws IOException
     */
    protected void receiveMultipart(HttpServletRequest request, HttpServletResponse response, HashMap<String, Object> params) throws IOException {
        ArrayList<FileApi.FileInfo> files = new ArrayList<FileApi.FileInfo>();
       
    MultipartParser parser = new MultipartParser(request, Integer.MAX_VALUE, true, true, null);
    FileApi api = getFileApi();
    Part part;
    while ((part = parser.readNextPart()) != null) {
      String name = part.getName();
     
      if (part.isParam()) {
        ParamPart paramPart = (ParamPart) part;
        Object value = paramPart.getStringValue();
View Full Code Here

    }

    private void processMultiPart(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        PrintWriter out = resp.getWriter();
        resp.setContentType("text/plain");
        MultipartParser mp = new MultipartParser(req, 2048);
        Part part = null;
        while ((part = mp.readNextPart()) != null) {
            String name = part.getName().trim();
            if (part.isParam()) {
                // it's a parameter part
                ParamPart paramPart = (ParamPart) part;
                String value = paramPart.getStringValue().trim();
View Full Code Here

TOP

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

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.