diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index c99b667fe0..df1b2d34a8 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -1704,8 +1704,8 @@ class Appwrite extends Source $responseHeaders ); - // Content-Length header was missing, file is less than max buffer size. - if (!array_key_exists('Content-Length', $responseHeaders)) { + // content-length header was missing, file is less than max buffer size. + if (!array_key_exists('content-length', $responseHeaders)) { $file = $this->call( 'GET', "/functions/{$func->getId()}/deployments/{$deployment['$id']}/download", @@ -1714,7 +1714,7 @@ class Appwrite extends Source $responseHeaders ); - $size = mb_strlen($file); + $size = strlen($file); if ($end > $size) { $end = $size - 1; @@ -1737,7 +1737,11 @@ class Appwrite extends Source return; } - $fileSize = $responseHeaders['Content-Length']; + $fileSize = $responseHeaders['content-length']; + + if ($end > $fileSize - 1) { + $end = $fileSize - 1; + } $deployment = new Deployment( $deployment['$id'], @@ -1920,7 +1924,7 @@ class Appwrite extends Source $responseHeaders ); - if (!\array_key_exists('Content-Length', $responseHeaders)) { + if (!\array_key_exists('content-length', $responseHeaders)) { $file = $this->call( 'GET', "/sites/{$site->getId()}/deployments/{$deployment['$id']}/download", @@ -1929,7 +1933,7 @@ class Appwrite extends Source $responseHeaders ); - $size = mb_strlen($file); + $size = strlen($file); if ($end > $size) { $end = $size - 1; @@ -1951,7 +1955,11 @@ class Appwrite extends Source return; } - $fileSize = $responseHeaders['Content-Length']; + $fileSize = $responseHeaders['content-length']; + + if ($end > $fileSize - 1) { + $end = $fileSize - 1; + } $siteDeployment = new SiteDeployment( $deployment['$id'],