Package com.lin.test.action

Source Code of com.lin.test.action.TestAction

package com.lin.test.action;

import java.io.File;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.common.util.FileUpload;
import com.common.util.ImgUtils;

@Component
@Transactional
public class TestAction {
  private File photof;
  private String photofFileName;//格式固定 上传文件名
  private String photofContentType; //格式固定 上传文件格式

  public String toSave(){
    return "toSave";
  }
  public String save(){
    int start = (int) System.currentTimeMillis();   // 开始时间
    System.out.println("save");
    System.out.println("源文件大小:"+photof.length()/1024+"KB");
    String uploadDir="d:\\del\\upload\\";
    String outPutDir="d:\\del\\yasuo\\";
    String photo= FileUpload.uploadFile(photof, uploadDir, photofFileName);
    String outPutFileName=photo.substring(0,36)+"_min.jpg";
    String uploadFileDir=uploadDir+photo;
    String outPutFileDir=outPutDir+outPutFileName;
    ImgUtils imgUtils=new ImgUtils();
    Long imgBig_Size= imgUtils.getPicSize(uploadFileDir)/1024;
    System.out.println("上传后源文件大小:"+imgBig_Size+"KB");
    imgUtils.compressPic(uploadDir,outPutDir , photo, outPutFileName,500,1000,true);
    System.out.println("压缩后的文件大小:"+imgUtils.getPicSize(outPutFileDir)/1024+"KB");
    int end = (int) System.currentTimeMillis(); // 结束时间
    int re = end-start; // 但图片生成处理时间
    System.out.println("共用时:"+re+"毫秒");
    return "save";
  }
 
  public void cao(){
   
  }
 
  public File getPhotof() {
    return photof;
  }
  public void setPhotof(File photof) {
    this.photof = photof;
  }
  public String getPhotofFileName() {
    return photofFileName;
  }
  public void setPhotofFileName(String photofFileName) {
    this.photofFileName = photofFileName;
  }
  public String getPhotofContentType() {
    return photofContentType;
  }
  public void setPhotofContentType(String photofContentType) {
    this.photofContentType = photofContentType;
  }
}
TOP

Related Classes of com.lin.test.action.TestAction

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.