| @@ 283-296 (lines=14) @@ | ||
| 280 | $this->createIndex(['filename' => 1, 'uploadDate' => 1]); |
|
| 281 | } |
|
| 282 | ||
| 283 | private function insertChunksFromFile($file, $fileInfo) |
|
| 284 | { |
|
| 285 | $length = $fileInfo['length']; |
|
| 286 | $chunkSize = $fileInfo['chunkSize']; |
|
| 287 | $fileId = $fileInfo['_id']; |
|
| 288 | $offset = 0; |
|
| 289 | $i = 0; |
|
| 290 | ||
| 291 | while ($offset < $length) { |
|
| 292 | $data = fread($file, $chunkSize); |
|
| 293 | $this->insertChunk($fileId, $data, $i++); |
|
| 294 | $offset += $chunkSize; |
|
| 295 | } |
|
| 296 | } |
|
| 297 | ||
| 298 | private function calculateMD5($file, $length) |
|
| 299 | { |
|
| @@ 306-319 (lines=14) @@ | ||
| 303 | return md5($data); |
|
| 304 | } |
|
| 305 | ||
| 306 | private function insertChunksFromBytes($bytes, $fileInfo) |
|
| 307 | { |
|
| 308 | $length = $fileInfo['length']; |
|
| 309 | $chunkSize = $fileInfo['chunkSize']; |
|
| 310 | $fileId = $fileInfo['_id']; |
|
| 311 | $offset = 0; |
|
| 312 | $i = 0; |
|
| 313 | ||
| 314 | while ($offset < $length) { |
|
| 315 | $data = mb_substr($bytes, $offset, $chunkSize, '8bit'); |
|
| 316 | $this->insertChunk($fileId, $data, $i++); |
|
| 317 | $offset += $chunkSize; |
|
| 318 | } |
|
| 319 | } |
|
| 320 | ||
| 321 | private function insertChunk($id, $data, $chunkNumber) |
|
| 322 | { |
|