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