Examples of FormFile


Examples of org.apache.struts.upload.FormFile

      throw new InputException(resources.getMessage(locale, "um.userSetNotFound",userSetId));
    }
   
    checkAccessRights(req, userSet.getGroup());
   
    FormFile csvFile = userImportForm.getCsvFile();
    if (csvFile != null && csvFile.getFileName() != null && csvFile.getFileName().length() != 0){
      try {
        InputStream inputStream = csvFile.getInputStream();
        UserManager userManager = new UserManager(locale,session);
       
        UserImportResult importResult = userManager.importData(inputStream, userImportForm.getCharacterSet(), userImportForm.getDelimiter(),userSet,
            userImportForm.getMergeSelection().equals("userName"),
            userImportForm.getMergeSelection().equals("msisdn"),
            userImportForm.getMergeSelection().equals("personnelNumber"));
        inputStream.close();
       
        req.setAttribute("userImportCounter", importResult.getUsersCreated());
        req.setAttribute("userUpdateCounter", importResult.getUsersUpdated());
        req.setAttribute("userIgnoreCounter", importResult.getUsersIgnored());
        req.setAttribute("userImportErrormessages", importResult.getErrorMessages());
       
      } catch (FileNotFoundException e){
        throw new InputException(resources.getMessage(locale, "um.fileNotFound",csvFile.getFileName()),e);
      } catch (IOException e) {
        throw new InputException(resources.getMessage(locale, "um.couldNotReadFile",csvFile.getFileName()),e);
      }
    } else {
      throw new InputException(resources.getMessage(locale, "um.fileNotFound"));
    }
   
View Full Code Here

Examples of org.g4studio.core.mvc.xstruts.upload.FormFile

   */
  public ActionForward doUpload(ActionMapping mapping, ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BaseActionForm cForm = (BaseActionForm) form;
    // 单个文件,如果是多个就cForm.getFile2()....支持最多5个文件
    FormFile myFile = cForm.getFile1();
    // 获取web应用根路径,也可以直接指定服务器任意盘符路径
    String savePath = getServlet().getServletContext().getRealPath("/") + "/upload/";
    // String savePath = "d:/upload/";
    // 检查路径是否存在,如果不存在则创建之
    File file = new File(savePath);
    if (!file.exists()) {
      file.mkdir();
    }
    // 文件按天归档
    savePath = savePath + G4Utils.getCurDate() + "/";
    File file1 = new File(savePath);
    if (!file1.exists()) {
      file1.mkdir();
    }
    // 文件真实文件名
    String fileName = myFile.getFileName();
    // 我们一般会根据某种命名规则对其进行重命名
    // String fileName = ;
    File fileToCreate = new File(savePath, fileName);
    // 检查同名文件是否存在,不存在则将文件流写入文件磁盘系统
    if (!fileToCreate.exists()) {
      FileOutputStream os = new FileOutputStream(fileToCreate);
      os.write(myFile.getFileData());
      os.flush();
      os.close();
    } else {
      // 此路径下已存在同名文件,是否要覆盖或给客户端提示信息由你自己决定
      FileOutputStream os = new FileOutputStream(fileToCreate);
      os.write(myFile.getFileData());
      os.flush();
      os.close();
    }
    // 我们通常还会把这个文件的相关信息持久化到数据库
    Dto inDto = cForm.getParamAsDto(request);
    inDto.put("title", G4Utils.isEmpty(inDto.getAsString("title")) ? fileName : inDto.getAsString("title"));
    inDto.put("filesize", myFile.getFileSize());
    inDto.put("path", savePath + fileName);
    demoService.doUpload(inDto);
    setOkTipMsg("文件上传成功", response);
    return mapping.findForward(null);
  }
View Full Code Here

Examples of org.wymiwyg.wrhapi.util.parameterparser.FormFile

   *      org.wymiwyg.wrhapi.Response)
   */
  public void handle(Request request, Response response)
      throws HandlerException {
    MultiPartBody body = ParameterUtil.parseMultipart(request);
    final FormFile formFile = body.getFormFileParameterValues("file")[0];
    final String locationString = body.getTextParameterValues("location")[0];
    final Model editableModel = ModelFactory.createDefaultModel();
    final Resource infoBitResource = editableModel.createResource();
   
    infoBitResource.addProperty(DISCOBITS.mediaType, formFile
        .getMimeType().toString());
    infoBitResource.addProperty(DISCOBITS.bytes, editableModel
        .createTypedLiteral(formFile.getContent()));
    infoBitResource.addProperty(RDF.type, DISCOBITS.InfoBit);
    store.perform(identity, new StoreTransaction() {

      public void execute(SourceStoreView storeView) {
        NamedNode locationNode = new NamedNodeImpl(locationString);
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.