package up6.store;

import java.io.ByteArrayOutputStream;

import org.apache.commons.fileupload.FileItem;

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

public class MinioBlockWriter extends FileBlockWriter{

    public MinioBlockWriter() {
        this.storage=StorageType.Minio;
    }

    /**
     * 生成UploadId
     */
    public String make(FileInf file)
    {	
        String ext = PathTool.getExtention(file.pathSvr);
        byte[] buf = new byte[0];
        String fileID = MinioTool.CreateMultipartUpload(file.S3Key());
        return fileID;
    }

    public String write(FileInf file, ByteArrayOutputStream ostm)
    {
        byte[] data = ostm.toByteArray();        
        return MinioTool.UploadPart(file.S3Key(), file.blockIndex, file.minio_id, data);
    }

}
