com.github.yingzhuo.fastdfs.springboot.domain.upload.FastFile Maven / Gradle / Ivy
The newest version!
package com.github.yingzhuo.fastdfs.springboot.domain.upload;
import com.github.yingzhuo.fastdfs.springboot.domain.fdfs.MetaData;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Collections;
import java.util.Set;
/**
* 上传普通文件
*
* @author tobato
*/
public class FastFile implements Serializable {
/**
* 输入流
*/
protected InputStream inputStream;
/**
* 文件大小
*/
protected long fileSize;
/**
* 文件扩展名
*/
protected String fileExtName;
/**
* 文件元数据
*/
protected Set metaDataSet;
/**
* 上传文件分组
*/
protected String groupName;
public FastFile(InputStream inputStream, long fileSize,
String fileExtName, Set metaDataSet) {
this.inputStream = inputStream;
this.fileSize = fileSize;
this.fileExtName = fileExtName;
this.metaDataSet = metaDataSet;
}
protected FastFile() {
}
public InputStream getInputStream() {
return inputStream;
}
public long getFileSize() {
return fileSize;
}
public String getFileExtName() {
return fileExtName;
}
public Set getMetaDataSet() {
return metaDataSet != null ? Collections.unmodifiableSet(metaDataSet) : Collections.emptySet();
}
public String getGroupName() {
return groupName;
}
/**
* 构造模式
*/
public static class Builder extends AbstractFastFileBuilder {
@Override
public Builder withFile(InputStream inputStream, long fileSize, String fileExtName) {
super.withFile(inputStream, fileSize, fileExtName);
return this;
}
@Override
public Builder withMetaData(String name, String value) {
super.withMetaData(name, value);
return this;
}
@Override
public Builder withMetaData(Set metaDataSet) {
super.withMetaData(metaDataSet);
return this;
}
@Override
public Builder toGroup(String groupName) {
super.toGroup(groupName);
return this;
}
/**
* 构造上传文件对象
*/
public FastFile build() {
FastFile file = new FastFile();
file.inputStream = this.inputStream;
file.fileExtName = this.fileExtName;
file.fileSize = this.fileSize;
file.metaDataSet = this.metaDataSet;
file.groupName = this.groupName;
return file;
}
}
}