package up6.store;

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

/**
 * FastDFS数据写入器
 * @author qwl
 *
 */
public class DfsBlockWriter extends FileBlockWriter{

    public DfsBlockWriter() {
        this.storage= StorageType.FastDFS;
    }
	
	public String CreateFile(String pathSvr,long lenLoc)
	{
		String ext = PathTool.getExtention(pathSvr);
		byte[] buf = new byte[0];
		String id = FastDFSTool.upload(buf, ext);
		return id;
	}
	
	public void write(long offset,String pathSvr,FileItem block)
	{
		FastDFSTool.write(pathSvr, offset, block);
	}
	
	public void write(long offset,String pathSvr,ByteArrayOutputStream ostm)
	{
		byte[] data = ostm.toByteArray();
		FastDFSTool.write(pathSvr, data);		
	}
}