mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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:
1 parent
987d11c9f7
commit
8b1b42d89a
1 file changed
+15
-7
@@ -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'],
|
||||
|
||||
Reference in new issue
Block a user