Examples of FilePart


Examples of com.ning.http.client.FilePart

        private void checkFileBody(BoundRequestBuilder builder) {
            setResolvedContentType(null);
            if (this.fileParams != null) {
                //could be optimized, we know the size of this array.
                for (int i = 0; i < this.fileParams.length; i++) {
                    builder.addBodyPart(new FilePart(this.fileParams[i].paramName,
                            this.fileParams[i].file,
                            MimeTypes.getMimeType(this.fileParams[i].file.getName()),
                            encoding));
                }
                if (this.parameters != null) {
View Full Code Here

Examples of com.ning.http.multipart.FilePart

        }

        for (String key : files.keySet()) {
            Part filePart;
            try {
                filePart = new FilePart(key, files.get(key));
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
            parts.add(filePart);
        }
View Full Code Here

Examples of com.oreilly.servlet.multipart.FilePart

        }
        existingValues.addElement(value);
      }
      else if (part.isFile()) {
        // It's a file part
        FilePart filePart = (FilePart) part;
        String fileName = filePart.getFileName();
        if (fileName != null) {
          filePart.setRenamePolicy(policy)// null policy is OK
          // The part actually contained a file
          filePart.writeTo(dir);
          files.put(name, new UploadedFile(dir.toString(),
                                           filePart.getFileName(),
                                           fileName,
                                           filePart.getContentType()));
        }
        else {
          // The field did not contain a file
          files.put(name, new UploadedFile(null, null, null, null));
        }
View Full Code Here

Examples of com.oreilly.servlet.multipart.FilePart

      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());
          if (fPart != null && fPart.getFileName() != null && type.startsWith("text") && (type.toLowerCase().endsWith("calendar"))) {
           
            // store the uploaded file by a temporary name
            CalendarManager calManager = CalendarManagerFactory.getInstance().getCalendarManager();
            String calID = ImportCalendarManager.getTempCalendarIDForUpload(ureq);
            File tmpFile = calManager.getCalendarFile(CalendarManager.TYPE_USER, calID);
            fPart.writeTo(tmpFile);
           
            // try to parse the tmp file
            Object calendar = calManager.readCalendar(CalendarManager.TYPE_USER, calID);
            if (calendar != null) {
              fileWritten = true;
View Full Code Here

Examples of com.ponxu.run.web.FileUpload.FilePart

  }

  // 上传
  public void post() {
    FileUpload fileUpload = new FileUpload(request());
    FilePart filePart = fileUpload.getFilePart(FILEDATA_NAME);

    String fileName = filePart.getFileName();
    File f = new File(fileName);
    fileName = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())
        + f.getName();

    if (Config.isCloudFoundry) {
      // CloudFoundry 使用mongodb
      MongoDAO.saveFile(fileName, filePart.getFileContent());
    } else {
      // 直接写入本地存储(SAE FileWrap)
      try {
        FileOutputStream out = new FileOutputStream(
            getSavePath(fileName));
        out.write(filePart.getFileContent());
        out.flush();
        out.close();
      } catch (Exception e) {
        LOG.error(e.getMessage(), e);
      }
View Full Code Here

Examples of org.apache.axis.tools.common.FilePart

    int prevPart = FilePart.COMMENT; // Suppresse newline before copyright
    String text;
    Iterator it = inputFile.getPartIterator();
    while (it.hasNext()) {
      FilePart fp = (FilePart) (it.next());
      if (!foundCopyright
        && (FilePart.DIRECTIVE == fp.getType()
          || FilePart.ENUM == fp.getType()
          || FilePart.PROTOTYPE == fp.getType())) {
        outputFile.write("#ifndef " + define);
        outputFile.newLine();
        outputFile.write("#define " + define);
        outputFile.newLine();
        foundCopyright = true;
      }

      switch (fp.getType()) {
        case FilePart.COMMENT :
          if (FilePart.COMMENT != prevPart)
            outputFile.newLine();
          prevPart = fp.getType();
          text = fp.toString().trim();
          StringTokenizer tkzr = new StringTokenizer(text, "\n\r");
          while (tkzr.hasMoreTokens()) {
            String line = tkzr.nextToken();
            if (-1 == line.indexOf("@author")) {
              outputFile.write(line);
              outputFile.newLine();
            }
          }
          break;

        case FilePart.DIRECTIVE :
          if (FilePart.DIRECTIVE != prevPart)
            outputFile.newLine();
          prevPart = fp.getType();
          generateDirective(fp, outputFile, inputFile.getName());
          break;

        case FilePart.TYPEDEF :
          prevPart = fp.getType();
          generateTypedef(fp, outputFile);
          break;

        case FilePart.METHOD :
        case FilePart.PROTOTYPE :
          if (FilePart.COMMENT != prevPart
            && FilePart.METHOD != prevPart
            && FilePart.PROTOTYPE != prevPart)
            outputFile.newLine();
          prevPart = fp.getType();
          generateFunctionPrototype(fp, outputFile);
          break;

        case FilePart.ENUM :
          Utils.rude(
            "Enums should be wrappered with a typedef so "
              + "they appear the same in C and C++",
            inputFile.getName(),
            0,
            fp.toString());
          break;
          // do nothing for other file parts
      }
    }
View Full Code Here

Examples of org.apache.axis.tools.common.FilePart

   */
  private void parseFile(InputCppSourceCode inputFile, Tracer outputFile)
    throws Exception {
    Iterator it = inputFile.getPartIterator();
    while (it.hasNext()) {
      FilePart fp = (FilePart) (it.next());
      if (fp.getType() == FilePart.METHOD) {
        MethodPart mp = (MethodPart) fp;
        outputFile.writeTrace(mp.getOriginalSignature() + "{");
        outputFile.traceEntry(mp.getSignature());
        BodyPart[] bps = mp.getBodyParts();

        int returnCount = 0,
          catchCount = 0,
          returnIndex = 0,
          catchIndex = 0;
        for (int i = 0; i < bps.length - 1; i++)
          if (bps[i].isReturn())
            returnCount++;
        for (int i = 0; i < bps.length - 1; i++)
          if (bps[i].isCatch())
            catchCount++;

        for (int i = 0; i < bps.length; i++) {
          outputFile.writeTrace(bps[i].getCodeFragment());
          if (bps[i].isReturn()) {
            if (returnCount > 1)
              returnIndex++;
            outputFile.traceExit(
              bps[i].getReturnValue(),
              returnIndex);
          } else if (bps[i].isCatch()) {
            if (catchCount > 1)
              catchIndex++;
            outputFile.traceCatch(
              bps[i].getCaughtValue(),
              catchIndex);
          } else if (i < bps.length - 1) {
            if (returnCount > 1)
              returnIndex++;
            outputFile.traceExit(returnIndex);
          }
        }
      } else {
        outputFile.writeTrace(fp.toString());
      }
    }
  }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.FilePart

  private void processMultipartRequest(ModelMap<String, Object> parameters,
      PostMethod postMethod, File[] files) throws FileNotFoundException {
    List<Part> parts = new ArrayList<Part>();
    int index = 0;
    for (File f : files) {
      parts.add(new FilePart("file_" + index++, f.getName(), f));
    }
    postMethod.setRequestEntity(new MultipartRequestEntity(parts
        .toArray(new Part[] {}), postMethod.getParams()));
  }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.FilePart

   {
      HttpClient client = new HttpClient();
      List<Part> partsList = new ArrayList<Part>();
      partsList.add(new StringPart("part1", "This is Value 1"));
      partsList.add(new StringPart("part2", "This is Value 2"));
      partsList.add(new FilePart("data.txt", LocateTestData.getTestData("data.txt")));
      Part[] parts = partsList.toArray(new Part[partsList.size()]);
      PostMethod method = new PostMethod(TEST_URI);
      RequestEntity entity = new MultipartRequestEntity(parts, method.getParams());
      method.setRequestEntity(entity);
      int status = client.executeMethod(method);
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.FilePart

                                             new UsernamePasswordCredentials(userNameAndPassword[0],
                                                                             userNameAndPassword[1]));
        }

        for (Map.Entry<String, byte[]> e : uploads.entrySet()) {
            method.addPart(new FilePart("filepath",
                           new ByteArrayPartSource(e.getKey(), e.getValue())));
        }
        client.executeMethod(method);
        return method;
    }
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.