Client
9 months ago
.htaccess
9 months ago
Box.php
9 months ago
Cache.php
9 months ago
ChunkedDownload.php
9 months ago
ChunkedUpload.php
9 months ago
DirIterator.php
9 months ago
index.html
9 months ago
web.config
9 months ago
ChunkedDownload.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JetBackup\Destination\Vendors\Box; |
| 4 | |
| 5 | use JetBackup\Destination\Integration\DestinationChunkedDownload; |
| 6 | |
| 7 | if (!defined( '__JETBACKUP__')) die('Direct access is not allowed'); |
| 8 | |
| 9 | class ChunkedDownload implements DestinationChunkedDownload { |
| 10 | |
| 11 | private Box $_client; |
| 12 | private string $_file_id; |
| 13 | private string $_destination; |
| 14 | |
| 15 | public function __construct(Box $client, $file_id, $destination) { |
| 16 | $this->_client = $client; |
| 17 | $this->_file_id = $file_id; |
| 18 | $this->_destination = $destination; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * @return string |
| 23 | */ |
| 24 | public function download(int $start, int $end):int { |
| 25 | return $this->_client->_retries(function() use ($start, $end) { |
| 26 | $response = $this->_client->getClient()->download($this->_file_id, $this->_destination, $start, $end); |
| 27 | return (int) $response->Headers->{'content-length'}; |
| 28 | }, "Failed downloading chunk"); |
| 29 | } |
| 30 | } |