Package com.jeecms.common.fck

Examples of com.jeecms.common.fck.ResourceType


    out.close();
  }

  private UploadResponse doUpload(HttpServletRequest request, String typeStr,
      String currentFolderStr, Boolean mark) throws Exception {
    ResourceType type = ResourceType.getDefaultResourceType(typeStr);
    try {
      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
      // We upload just one file at the same time
      MultipartFile uplFile = multipartRequest.getFileMap().entrySet()
          .iterator().next().getValue();
      CmsUser user = CmsUtils.getUser(request);
      int fileSize = (int) (uplFile.getSize() / 1024);
      // 文件太大,不允许上传
      if (!user.isAllowMaxFile(fileSize)) {
        log.warn("member fck upload warn: not allow max file: {}",
            fileSize);
        return UploadResponse.getFileUploadDisabledError(request);
      }
      // 文件上传今日额度已经用完
      if (!user.isAllowPerDay(fileSize)) {
        log.warn("member fck upload warn: not allow per day: {}",
            fileSize);
        return UploadResponse.getFileUploadDisabledError(request);
      }
      // Some browsers transfer the entire source path not just the
      // filename
      String filename = FilenameUtils.getName(uplFile
          .getOriginalFilename());
      log.debug("Parameter NewFile: {}", filename);
      String ext = FilenameUtils.getExtension(filename);
      // 不允许上传的文件后缀
      if (!user.isAllowSuffix(ext)) {
        log.warn("member fck upload warn:"
            + " not allow file extension: {}", ext);
        return UploadResponse.getFileUploadDisabledError(request);
      }
      if (type.isDeniedExtension(ext)) {
        return UploadResponse.getInvalidFileTypeError(request);
      }
      if (type.equals(ResourceType.IMAGE)
          && !ImageUtils.isImage(uplFile.getInputStream())) {
        return UploadResponse.getInvalidFileTypeError(request);
      }
      String fileUrl;
      CmsSite site = CmsUtils.getSite(request);
      MarkConfig conf = site.getConfig().getMarkConfig();
      if (mark == null) {
        mark = conf.getOn();
      }
      boolean isImg = type.equals(ResourceType.IMAGE);
      if (site.getConfig().getUploadToDb()) {
        if (mark && isImg) {
          File tempFile = mark(uplFile, conf);
          fileUrl = dbFileMng.storeByExt(site.getUploadPath(), ext,
              new FileInputStream(tempFile));
View Full Code Here


    out.close();
  }

  private UploadResponse doUpload(HttpServletRequest request, String typeStr,
      String currentFolderStr, Boolean mark) throws Exception {
    ResourceType type = ResourceType.getDefaultResourceType(typeStr);
    try {
      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
      // We upload just one file at the same time
      MultipartFile uplFile = multipartRequest.getFileMap().entrySet()
          .iterator().next().getValue();
      // Some browsers transfer the entire source path not just the
      // filename
      String filename = FilenameUtils.getName(uplFile
          .getOriginalFilename());
      log.debug("Parameter NewFile: {}", filename);
      String ext = FilenameUtils.getExtension(filename);
      if (type.isDeniedExtension(ext)) {
        return UploadResponse.getInvalidFileTypeError(request);
      }
      if (type.equals(ResourceType.IMAGE)
          && !ImageUtils.isImage(uplFile.getInputStream())) {
        return UploadResponse.getInvalidFileTypeError(request);
      }
      String fileUrl;
      CmsSite site = CmsUtils.getSite(request);
      MarkConfig conf = site.getConfig().getMarkConfig();
      if (mark == null) {
        mark = conf.getOn();
      }
      boolean isImg = type.equals(ResourceType.IMAGE);
      if (site.getConfig().getUploadToDb()) {
        if (mark && isImg) {
          File tempFile = mark(uplFile, conf);
          fileUrl = dbFileMng.storeByExt(site.getUploadPath(), ext,
              new FileInputStream(tempFile));
View Full Code Here

TOP

Related Classes of com.jeecms.common.fck.ResourceType

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.