MCPcopy Create free account
hub / github.com/dfinity/cancan / chunkFile

Function chunkFile

scripts/seed.ts:132–153  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

130}
131
132function chunkFile(filePath) {
133 const file = fs.readFileSync(filePath);
134 const fileStats = fs.statSync(filePath);
135 const fileSize = fileStats.size;
136
137 let chunk = 1;
138 const chunks: number[][] = [];
139 for (
140 let byteStart = 0;
141 byteStart < fileSize;
142 byteStart += MAX_CHUNK_SIZE, chunk++
143 ) {
144 const videoSlice = file.buffer.slice(
145 byteStart,
146 Math.min(fileSize, byteStart + MAX_CHUNK_SIZE)
147 );
148 const sliceToNat = encodeArrayBuffer(videoSlice);
149 chunks.push(sliceToNat);
150 }
151
152 return chunks;
153}
154
155function generateSeedData() {
156 const userNames = [

Callers 1

uploadVideoFunction · 0.85

Calls 1

encodeArrayBufferFunction · 0.70

Tested by

no test coverage detected