예제 #1
0
  public String uploadToBin() {

    super.setPageTitle("label.media.binmanagement");

    super.getServletRequest().setAttribute("Type", this.getType());
    if (isBlank()) {
      setErrorMessage(getText("error.upload.required"));
      return INPUT;
    }
    Context ctx = super.getContext();
    Integer merchantid = ctx.getMerchantid();
    FileModule futil = (FileModule) SpringUtil.getBean("localfile");
    ContentCategoryType contentType = FileUtil.getContentCategoryType(uploadContentType);
    if (ContentCategoryType.IMAGE.equals(contentType)) {

      try {
        futil.copyFile(
            merchantid,
            "core.bin.images",
            getUpload(),
            getUploadFileName(),
            getUploadContentType());
      } catch (FileException e) {
        log.error(e);
        super.setTechnicalMessage();
        return INPUT;
      }
    } else if (ContentCategoryType.FLASH.equals(contentType)) {
      try {
        futil.copyFile(
            merchantid, "core.bin.flash", getUpload(), getUploadFileName(), getUploadContentType());
      } catch (Exception e) {
        log.error(e);
        super.setTechnicalMessage();
        return INPUT;
      }
    } else if (ContentCategoryType.FILE.equals(contentType)) {
      try {
        futil.copyFile(
            merchantid, "core.bin.files", getUpload(), getUploadFileName(), getUploadContentType());
      } catch (Exception e) {
        log.error(e);
        super.setTechnicalMessage();
        return INPUT;
      }
    } else {
      setErrorMessage(getText("error.bin.upload.invalid.type"));
      return INPUT;
    }
    super.setSuccessMessage();
    return SUCCESS;
  }
예제 #2
0
 public String getSmallImagePath() {
   return FileUtil.getSmallProductImagePath(this.getMerchantId(), this.getProductImage());
 }