@@ 133-146 (lines=14) @@ | ||
130 | return $fileDocument['_id']; |
|
131 | } |
|
132 | ||
133 | private function insertChunksFromFile($file, $fileInfo) |
|
134 | { |
|
135 | $length = $fileInfo['length']; |
|
136 | $chunkSize = $fileInfo['chunkSize']; |
|
137 | $fileId = $fileInfo['_id']; |
|
138 | $offset = 0; |
|
139 | $i = 0; |
|
140 | ||
141 | while ($offset < $length) { |
|
142 | $data = fread($file, $chunkSize); |
|
143 | $this->insertChunk($fileId, $data, $i++); |
|
144 | $offset += $chunkSize; |
|
145 | } |
|
146 | } |
|
147 | ||
148 | private function calculateMD5($file, $length) |
|
149 | { |
|
@@ 186-199 (lines=14) @@ | ||
183 | return $metadata; |
|
184 | } |
|
185 | ||
186 | private function insertChunksFromBytes($bytes, $fileInfo) |
|
187 | { |
|
188 | $length = $fileInfo['length']; |
|
189 | $chunkSize = $fileInfo['chunkSize']; |
|
190 | $fileId = $fileInfo['_id']; |
|
191 | $offset = 0; |
|
192 | $i = 0; |
|
193 | ||
194 | while ($offset < $length) { |
|
195 | $data = mb_substr($bytes, $offset, $chunkSize, '8bit'); |
|
196 | $this->insertChunk($fileId, $data, $i++); |
|
197 | $offset += $chunkSize; |
|
198 | } |
|
199 | } |
|
200 | ||
201 | private function insertChunk($id, $data, $chunkNumber) |
|
202 | { |