import SparkMD5 from "spark-md5"
export function createChunk(file,index,chunkSize){
    return new Promise((resolve, reject)=>{

        const sp = new SparkMD5()
        const start = index*chunkSize;
        const end = start + chunkSize;

        const spark = sp.ArrayBuffer();

        const fileReader = new FileReader();
        const blob = file.slice(start,end);
        fileReader.onload = (e)=>{
            spark.append(e.target.result);
            resolve({
                start,
                end,
                index,
                hash:spark.end(),
                blob,
            })
        }
    } )
}