fix: deployment download bugs in exportDeploymentData and exportSiteDeploymentData

- Use lowercase 'content-length' header key (Target::call stores headers lowercase via strtolower)
- Use strlen instead of mb_strlen for binary file data (mb_strlen misinterprets gzip bytes as UTF-8)
- Cap $end to $fileSize - 1 before first chunked Range request (server rejects $end >= $size with 416)
This commit is contained in:
Prem Palanisamy committed 2026-02-25 09:27:00 +00:00
1 parent 987d11c9f7
commit 8b1b42d89a
1 file changed
+15 -7
+15 -7
View File
@@ -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'],