package up6.store;

import java.io.ByteArrayOutputStream;
import org.apache.commons.fileupload.FileItem;

import up6.PathTool;
import up6.model.FileInf;

public class DfsBlockWriter extends FileBlockWriter{

    public DfsBlockWriter() {
        this.storage=StorageType.FastDFS;
    }

    public String make(FileInf file)
    {
        String fileID="";
        String ext = PathTool.getExtention(file.pathSvr);
        byte[] buf = new byte[0];
        fileID = FastDFSTool.upload(buf, ext);
        return fileID;
    }

    public void write(long offset, String pathSvr, FileItem block)
    {
        FastDFSTool.write(pathSvr, offset, block);
    }

    /**
     * 参数：pathSvr
     */
    public String write(FileInf file, ByteArrayOutputStream ostm)
    {
        byte[] data = ostm.toByteArray();
        FastDFSTool.write(file.fastdfs_id, data);
        return "";
    }
}
