All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.net.wanmo.common.http.jdk.pojo.UploadFile Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package cn.net.wanmo.common.http.jdk.pojo;

import cn.net.wanmo.common.security.Digests;
import cn.net.wanmo.common.util.StringUtil;

import java.io.File;
import java.io.FileInputStream;
import java.io.Serializable;

/**
 * 上传的文件
 */
public class UploadFile implements Serializable {
    /**
     * 文件名
     */
    private String filename;
    /**
     * 文件
     */
    private File file;
    /**
     * 文件摘要
     */
    private String digest = "";

    public UploadFile() {
    }

    public String getFilename() {
        if (this.filename == null || this.filename.trim() == "") {
            this.filename = file.getName();
        }
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
        try {
            this.digest = Digests.sha1Hex(new FileInputStream(file));
        } catch (Exception e) {
            this.digest = StringUtil.EMPTY;
        }
    }

    public String getDigest() {
        return digest;
    }

    public void setDigest(String digest) {
        this.digest = digest;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy