From 031469a16ef94354a981406823552a4c065aaadd Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 31 Jul 2026 10:21:01 +0100 Subject: [PATCH] chore(storage): migrate to storage 4.0 --- composer.json | 4 +-- composer.lock | 28 +++++++++---------- .../Functions/Http/Deployments/Create.php | 13 +++++++-- .../Http/Deployments/Download/Get.php | 6 ++-- .../Http/Deployments/Duplicate/Create.php | 2 +- .../Modules/Functions/Workers/Screenshots.php | 3 +- .../Health/Http/Health/Storage/Get.php | 5 ++-- .../Http/Migrations/CSV/Imports/Create.php | 7 +++-- .../Http/Migrations/JSON/Imports/Create.php | 7 +++-- .../Modules/Sites/Http/Deployments/Create.php | 13 +++++++-- .../Sites/Http/Deployments/Download/Get.php | 6 ++-- .../Http/Deployments/Duplicate/Create.php | 2 +- .../Storage/Http/Buckets/Files/Create.php | 20 +++++++++---- .../Http/Buckets/Files/Download/Get.php | 12 ++++---- .../Http/Buckets/Files/Preview/Get.php | 2 +- .../Storage/Http/Buckets/Files/Push/Get.php | 12 ++++---- .../Storage/Http/Buckets/Files/View/Get.php | 12 ++++---- src/Appwrite/Platform/Workers/Messaging.php | 2 +- 18 files changed, 91 insertions(+), 65 deletions(-) diff --git a/composer.json b/composer.json index c0c528c006..0670943532 100644 --- a/composer.json +++ b/composer.json @@ -87,7 +87,7 @@ "utopia-php/lock": "0.2.*", "utopia-php/logger": "0.8.*", "utopia-php/messaging": "^2.0", - "utopia-php/migration": "^1.18.0", + "utopia-php/migration": "^1.21.0", "utopia-php/platform": "^1.0@RC", "utopia-php/pools": "1.*", "utopia-php/span": "3.0.*", @@ -95,7 +95,7 @@ "utopia-php/queue": "^0.22", "utopia-php/servers": "0.4.*", "utopia-php/registry": "0.5.*", - "utopia-php/storage": "^3.1", + "utopia-php/storage": "^4.0", "utopia-php/system": "0.10.*", "utopia-php/telemetry": "^0.4", "utopia-php/user-agent": "0.1.*", diff --git a/composer.lock b/composer.lock index 700bc30981..87e219d399 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a811ab43bece6d9d01be1caab8a08a75", + "content-hash": "dd9294ec6748886d8819aa3c8ae438f8", "packages": [ { "name": "adhocore/jwt", @@ -4358,16 +4358,16 @@ }, { "name": "utopia-php/migration", - "version": "1.20.1", + "version": "1.21.0", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "9dc829536b545d548e1cd4a924776c625c3edab8" + "reference": "4806dce18d6793b1cfd1b513b425245761933670" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/9dc829536b545d548e1cd4a924776c625c3edab8", - "reference": "9dc829536b545d548e1cd4a924776c625c3edab8", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/4806dce18d6793b1cfd1b513b425245761933670", + "reference": "4806dce18d6793b1cfd1b513b425245761933670", "shasum": "" }, "require": { @@ -4378,7 +4378,7 @@ "php": ">=8.5", "utopia-php/database": "^6.0.0", "utopia-php/dsn": "0.2.*", - "utopia-php/storage": "3.*" + "utopia-php/storage": "4.*" }, "require-dev": { "ext-pdo": "*", @@ -4407,9 +4407,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/1.20.1" + "source": "https://github.com/utopia-php/migration/tree/1.21.0" }, - "time": "2026-07-22T04:10:07+00:00" + "time": "2026-07-31T09:11:04+00:00" }, { "name": "utopia-php/mongo", @@ -4926,16 +4926,16 @@ }, { "name": "utopia-php/storage", - "version": "3.1.0", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "38bfc0c14a16a7de2a86b3331865dad1230ed739" + "reference": "ad05f341a9a62a4de73c5312f4ab6fe69f7d0051" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/38bfc0c14a16a7de2a86b3331865dad1230ed739", - "reference": "38bfc0c14a16a7de2a86b3331865dad1230ed739", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/ad05f341a9a62a4de73c5312f4ab6fe69f7d0051", + "reference": "ad05f341a9a62a4de73c5312f4ab6fe69f7d0051", "shasum": "" }, "require": { @@ -4970,9 +4970,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/3.1.0" + "source": "https://github.com/utopia-php/storage/tree/4.0.0" }, - "time": "2026-07-22T15:57:57+00:00" + "time": "2026-07-23T20:37:10+00:00" }, { "name": "utopia-php/system", diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php index dce271a92f..568a125dc0 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php @@ -236,7 +236,7 @@ class Create extends Action } if ($deployment->isEmpty()) { - $deviceForFunctions->prepareUpload($path, $metadata['content_type'] ?? '', $chunks, $metadata); + $deviceForFunctions->prepare($path, $metadata['content_type'] ?? '', $chunks, $metadata); if (!empty($contentRange)) { $deployment = $deployments->upload($function, $deployment->setAttributes([ @@ -266,7 +266,14 @@ class Create extends Action return; } - $chunksUploaded = $deviceForFunctions->uploadChunk($deviceForLocal->read($fileTmpName), $path, $chunk, $chunks, $metadata); + $chunksUploaded = $deviceForFunctions->upload( + $deviceForLocal->read($fileTmpName), + $path, + $metadata['content_type'] ?? '', + $chunk, + $chunks, + $metadata + ); if (empty($chunksUploaded)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed moving file'); @@ -295,7 +302,7 @@ class Create extends Action $chunksUploaded = max($uploaded, $chunksUploaded, (int) ($metadata['chunks'] ?? 0)); if ($chunksUploaded === $chunks && $uploaded < $chunks) { - $deviceForFunctions->finalizeUpload($path, $chunks, $metadata); + $deviceForFunctions->finalize($path, $chunks, $metadata); $fileSize = $deviceForFunctions->getFileSize($path); diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Download/Get.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Download/Get.php index 2b950d0afe..b92a4a156a 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Download/Get.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Download/Get.php @@ -158,14 +158,14 @@ class Get extends Action ->addHeader('Content-Length', $end - $start + 1) ->setStatusCode(Response::STATUS_CODE_PARTIALCONTENT); - $response->send($device->read($path, $start, ($end - $start + 1))); + $response->send((string) $device->read($path, $start, ($end - $start + 1))); return; } if ($size > APP_STORAGE_READ_BUFFER) { for ($i = 0; $i < ceil($size / MAX_OUTPUT_CHUNK_SIZE); $i++) { $response->chunk( - $device->read( + (string) $device->read( $path, ($i * MAX_OUTPUT_CHUNK_SIZE), min(MAX_OUTPUT_CHUNK_SIZE, $size - ($i * MAX_OUTPUT_CHUNK_SIZE)) @@ -174,7 +174,7 @@ class Get extends Action ); } } else { - $response->send($device->read($path)); + $response->send((string) $device->read($path)); } } } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php index a0721d56cf..bf8258fa47 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php @@ -112,7 +112,7 @@ class Create extends Action $destination = ''; if ($hasSource) { $destination = $deviceForFunctions->getPath($deploymentId . '.' . \pathinfo('code.tar.gz', PATHINFO_EXTENSION)); - $deviceForFunctions->transfer($path, $destination, $deviceForFunctions); + $deviceForFunctions->copy($path, $destination); } // Cloning the source deployment's attributes onto the new one, with diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Screenshots.php b/src/Appwrite/Platform/Modules/Functions/Workers/Screenshots.php index 7bd058fff6..0361409a2f 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Screenshots.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Screenshots.php @@ -16,6 +16,7 @@ use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\Platform\Action; +use Utopia\Psr7\Stream; use Utopia\Queue\Message; use Utopia\Span\Span; use Utopia\Storage\Device; @@ -171,7 +172,7 @@ class Screenshots extends Action $fileName = $fileId . '.png'; $path = $deviceForFiles->getPath($fileName); $path = str_ireplace($deviceForFiles->getRoot(), $deviceForFiles->getRoot() . DIRECTORY_SEPARATOR . $bucket->getId(), $path); // Add bucket id to path after root - $success = $deviceForFiles->write($path, $screenshot, $mimeType); + $success = $deviceForFiles->write($path, new Stream($screenshot), $mimeType); if (!$success) { throw new \Exception("Screenshot failed to save"); diff --git a/src/Appwrite/Platform/Modules/Health/Http/Health/Storage/Get.php b/src/Appwrite/Platform/Modules/Health/Http/Health/Storage/Get.php index a437073339..a524cfac03 100644 --- a/src/Appwrite/Platform/Modules/Health/Http/Health/Storage/Get.php +++ b/src/Appwrite/Platform/Modules/Health/Http/Health/Storage/Get.php @@ -6,6 +6,7 @@ use Appwrite\Utopia\Response; use Utopia\Database\Document; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; +use Utopia\Psr7\Stream; use Utopia\Storage\Device; class Get extends Action @@ -42,11 +43,11 @@ class Get extends Action $path = $device->getPath(\uniqid('health', true)); try { - if (!$device->write($path, 'test', 'text/plain')) { + if (!$device->write($path, new Stream('test'), 'text/plain')) { throw new \Exception("Failed writing test file to {$device->getRoot()}"); } - $content = $device->read($path); + $content = (string) $device->read($path); if ($content !== 'test') { throw new \Exception("Failed reading test file from {$device->getRoot()}: content mismatch"); } diff --git a/src/Appwrite/Platform/Modules/Migrations/Http/Migrations/CSV/Imports/Create.php b/src/Appwrite/Platform/Modules/Migrations/Http/Migrations/CSV/Imports/Create.php index 61b1298fd9..a1802d6fa8 100644 --- a/src/Appwrite/Platform/Modules/Migrations/Http/Migrations/CSV/Imports/Create.php +++ b/src/Appwrite/Platform/Modules/Migrations/Http/Migrations/CSV/Imports/Create.php @@ -27,6 +27,7 @@ use Utopia\Migration\Transfer; use Utopia\Platform\Action; use Utopia\Platform\Enum; use Utopia\Platform\Scope\HTTP; +use Utopia\Psr7\Stream; use Utopia\Storage\Device; use Utopia\System\System; use Utopia\Validator\Boolean; @@ -132,7 +133,7 @@ class Create extends Action $newPath = $deviceForMigrations->getPath($migrationId . '_' . $fileId . '.csv'); if ($hasEncryption || $hasCompression) { - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); if ($hasEncryption) { $source = OpenSSL::decrypt( @@ -157,10 +158,10 @@ class Create extends Action } // Manual write after decryption and/or decompression - if (!$deviceForMigrations->write($newPath, $source, 'text/csv')) { + if (!$deviceForMigrations->write($newPath, new Stream($source), 'text/csv')) { throw new \Exception('Unable to copy file'); } - } elseif (!$deviceForFiles->transfer($path, $newPath, $deviceForMigrations)) { + } elseif (!$deviceForFiles->copy($path, $newPath, $deviceForMigrations)) { throw new \Exception('Unable to copy file'); } diff --git a/src/Appwrite/Platform/Modules/Migrations/Http/Migrations/JSON/Imports/Create.php b/src/Appwrite/Platform/Modules/Migrations/Http/Migrations/JSON/Imports/Create.php index 4bcba3edb3..3c0ca4c2e7 100644 --- a/src/Appwrite/Platform/Modules/Migrations/Http/Migrations/JSON/Imports/Create.php +++ b/src/Appwrite/Platform/Modules/Migrations/Http/Migrations/JSON/Imports/Create.php @@ -27,6 +27,7 @@ use Utopia\Migration\Transfer; use Utopia\Platform\Action; use Utopia\Platform\Enum; use Utopia\Platform\Scope\HTTP; +use Utopia\Psr7\Stream; use Utopia\Storage\Device; use Utopia\System\System; use Utopia\Validator\Boolean; @@ -131,7 +132,7 @@ class Create extends Action $newPath = $deviceForMigrations->getPath($migrationId . '_' . $fileId . '.json'); if ($hasEncryption || $hasCompression) { - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); if ($hasEncryption) { $source = OpenSSL::decrypt( @@ -156,10 +157,10 @@ class Create extends Action } // Manual write after decryption and/or decompression - if (!$deviceForMigrations->write($newPath, $source, 'application/json')) { + if (!$deviceForMigrations->write($newPath, new Stream($source), 'application/json')) { throw new \Exception('Unable to copy file'); } - } elseif (!$deviceForFiles->transfer($path, $newPath, $deviceForMigrations)) { + } elseif (!$deviceForFiles->copy($path, $newPath, $deviceForMigrations)) { throw new \Exception('Unable to copy file'); } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php index 5581e00751..e044366cd6 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php @@ -246,7 +246,7 @@ class Create extends Action } if ($deployment->isEmpty()) { - $deviceForSites->prepareUpload($path, $metadata['content_type'] ?? '', $chunks, $metadata); + $deviceForSites->prepare($path, $metadata['content_type'] ?? '', $chunks, $metadata); if (!empty($contentRange)) { $deployment = $deployments->upload($site, $deployment->setAttributes([ @@ -306,7 +306,14 @@ class Create extends Action return; } - $chunksUploaded = $deviceForSites->uploadChunk($deviceForLocal->read($fileTmpName), $path, $chunk, $chunks, $metadata); + $chunksUploaded = $deviceForSites->upload( + $deviceForLocal->read($fileTmpName), + $path, + $metadata['content_type'] ?? '', + $chunk, + $chunks, + $metadata + ); if (empty($chunksUploaded)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed moving file'); @@ -335,7 +342,7 @@ class Create extends Action $chunksUploaded = max($uploaded, $chunksUploaded, (int) ($metadata['chunks'] ?? 0)); if ($chunksUploaded === $chunks && $uploaded < $chunks) { - $deviceForSites->finalizeUpload($path, $chunks, $metadata); + $deviceForSites->finalize($path, $chunks, $metadata); $fileSize = $deviceForSites->getFileSize($path); $isNewDeployment = $deployment->isEmpty(); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Download/Get.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Download/Get.php index 73ef6e6328..170a3c7f2a 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Download/Get.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Download/Get.php @@ -157,14 +157,14 @@ class Get extends Action ->addHeader('Content-Length', $end - $start + 1) ->setStatusCode(Response::STATUS_CODE_PARTIALCONTENT); - $response->send($device->read($path, $start, ($end - $start + 1))); + $response->send((string) $device->read($path, $start, ($end - $start + 1))); return; } if ($size > APP_STORAGE_READ_BUFFER) { for ($i = 0; $i < ceil($size / MAX_OUTPUT_CHUNK_SIZE); $i++) { $response->chunk( - $device->read( + (string) $device->read( $path, ($i * MAX_OUTPUT_CHUNK_SIZE), min(MAX_OUTPUT_CHUNK_SIZE, $size - ($i * MAX_OUTPUT_CHUNK_SIZE)) @@ -173,7 +173,7 @@ class Get extends Action ); } } else { - $response->send($device->read($path)); + $response->send((string) $device->read($path)); } } } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php index 092cec9119..02e19f1f47 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php @@ -119,7 +119,7 @@ class Create extends Action $destination = ''; if ($hasSource) { $destination = $deviceForSites->getPath($deploymentId . '.' . \pathinfo('code.tar.gz', PATHINFO_EXTENSION)); - $deviceForSites->transfer($path, $destination, $deviceForSites); + $deviceForSites->copy($path, $destination); } $commands = []; diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Create.php b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Create.php index 6edee78565..af1ca9b3fb 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Create.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Create.php @@ -34,6 +34,7 @@ use Utopia\Http\Adapter\Swoole\Request; use Utopia\Lock\Exception\Contention as LockContention; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; +use Utopia\Psr7\Stream; use Utopia\Storage\Device; use Utopia\Storage\DeviceType; use Utopia\Storage\Validator\FileExt; @@ -287,7 +288,7 @@ class Create extends Action } if ($file->isEmpty()) { - $deviceForFiles->prepareUpload($path, $metadata['content_type'] ?? '', $chunks, $metadata); + $deviceForFiles->prepare($path, $metadata['content_type'] ?? '', $chunks, $metadata); if (!empty($contentRange)) { $doc = new Document([ @@ -357,7 +358,7 @@ class Create extends Action $chunksUploaded = max($uploaded, $chunksUploaded, (int) ($metadata['chunks'] ?? 0)); if ($chunksUploaded === $chunks && $uploaded < $chunks) { - $deviceForFiles->finalizeUpload($path, $chunks, $metadata); + $deviceForFiles->finalize($path, $chunks, $metadata); if (System::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled' && $bucket->getAttribute('antivirus', true) && $fileSize <= APP_LIMIT_ANTIVIRUS && $deviceForFiles->getType() === DeviceType::Local) { $antivirus = new Network( @@ -379,7 +380,7 @@ class Create extends Action // Compression $algorithm = $bucket->getAttribute('compression', Compression::NONE); if ($fileSize <= APP_STORAGE_READ_BUFFER && $algorithm != Compression::NONE) { - $data = $deviceForFiles->read($path); + $data = (string) $deviceForFiles->read($path); switch ($algorithm) { case Compression::ZSTD: $compressor = new Zstd(); @@ -399,7 +400,7 @@ class Create extends Action if ($bucket->getAttribute('encryption', true) && $fileSize <= APP_STORAGE_READ_BUFFER) { if (empty($data)) { - $data = $deviceForFiles->read($path); + $data = (string) $deviceForFiles->read($path); } $key = System::getEnv('_APP_OPENSSL_KEY_V1'); $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); @@ -407,7 +408,7 @@ class Create extends Action } if (!empty($data)) { - if (!$deviceForFiles->write($path, $data, $mimeType)) { + if (!$deviceForFiles->write($path, new Stream($data), $mimeType)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to save file'); } } @@ -516,7 +517,14 @@ class Create extends Action }; try { - $chunksUploaded = $deviceForFiles->uploadChunk($deviceForLocal->read($fileTmpName), $path, $chunk, $chunks, $metadata); + $chunksUploaded = $deviceForFiles->upload( + $deviceForLocal->read($fileTmpName), + $path, + $metadata['content_type'] ?? '', + $chunk, + $chunks, + $metadata + ); if (empty($chunksUploaded)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed uploading file'); diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Download/Get.php b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Download/Get.php index e5d82c7aa1..5282e81195 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Download/Get.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Download/Get.php @@ -159,7 +159,7 @@ class Get extends Action $source = ''; if (!empty($file->getAttribute('openSSLCipher'))) { // Decrypt - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); $source = OpenSSL::decrypt( $source, $file->getAttribute('openSSLCipher'), @@ -173,14 +173,14 @@ class Get extends Action switch ($file->getAttribute('algorithm', Compression::NONE)) { case Compression::ZSTD: if (empty($source)) { - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); } $compressor = new Zstd(); $source = $compressor->decompress($source); break; case Compression::GZIP: if (empty($source)) { - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); } $compressor = new GZIP(); $source = $compressor->decompress($source); @@ -197,14 +197,14 @@ class Get extends Action } if (!empty($rangeHeader)) { - $response->send($deviceForFiles->read($path, $start, ($end - $start + 1))); + $response->send((string) $deviceForFiles->read($path, $start, ($end - $start + 1))); return; } if ($size > APP_STORAGE_READ_BUFFER) { for ($i = 0; $i < ceil($size / MAX_OUTPUT_CHUNK_SIZE); $i++) { $response->chunk( - $deviceForFiles->read( + (string) $deviceForFiles->read( $path, ($i * MAX_OUTPUT_CHUNK_SIZE), min(MAX_OUTPUT_CHUNK_SIZE, $size - ($i * MAX_OUTPUT_CHUNK_SIZE)) @@ -213,7 +213,7 @@ class Get extends Action ); } } else { - $response->send($deviceForFiles->read($path)); + $response->send((string) $deviceForFiles->read($path)); } } } diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Preview/Get.php b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Preview/Get.php index 7ff22f3744..7c7eaacf71 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Preview/Get.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Preview/Get.php @@ -210,7 +210,7 @@ class Get extends Action $startTime = \microtime(true); - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); $downloadTime = \microtime(true) - $startTime; diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Push/Get.php b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Push/Get.php index 637d1b22e6..7622f9ee25 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Push/Get.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Push/Get.php @@ -151,7 +151,7 @@ class Get extends Action $source = ''; if (!empty($file->getAttribute('openSSLCipher'))) { // Decrypt - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); $source = OpenSSL::decrypt( $source, $file->getAttribute('openSSLCipher'), @@ -165,14 +165,14 @@ class Get extends Action switch ($file->getAttribute('algorithm', Compression::NONE)) { case Compression::ZSTD: if (empty($source)) { - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); } $compressor = new Zstd(); $source = $compressor->decompress($source); break; case Compression::GZIP: if (empty($source)) { - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); } $compressor = new GZIP(); $source = $compressor->decompress($source); @@ -189,7 +189,7 @@ class Get extends Action } if (!empty($rangeHeader)) { - $response->send($deviceForFiles->read($path, $start, ($end - $start + 1))); + $response->send((string) $deviceForFiles->read($path, $start, ($end - $start + 1))); return; } @@ -197,7 +197,7 @@ class Get extends Action if ($size > APP_STORAGE_READ_BUFFER) { for ($i = 0; $i < ceil($size / MAX_OUTPUT_CHUNK_SIZE); $i++) { $response->chunk( - $deviceForFiles->read( + (string) $deviceForFiles->read( $path, ($i * MAX_OUTPUT_CHUNK_SIZE), min(MAX_OUTPUT_CHUNK_SIZE, $size - ($i * MAX_OUTPUT_CHUNK_SIZE)) @@ -206,7 +206,7 @@ class Get extends Action ); } } else { - $response->send($deviceForFiles->read($path)); + $response->send((string) $deviceForFiles->read($path)); } } } diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/View/Get.php b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/View/Get.php index 8214cdbfa1..aa79178921 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/View/Get.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/View/Get.php @@ -170,7 +170,7 @@ class Get extends Action $source = ''; if (!empty($file->getAttribute('openSSLCipher'))) { // Decrypt - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); $source = OpenSSL::decrypt( $source, $file->getAttribute('openSSLCipher'), @@ -184,14 +184,14 @@ class Get extends Action switch ($file->getAttribute('algorithm', Compression::NONE)) { case Compression::ZSTD: if (empty($source)) { - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); } $compressor = new Zstd(); $source = $compressor->decompress($source); break; case Compression::GZIP: if (empty($source)) { - $source = $deviceForFiles->read($path); + $source = (string) $deviceForFiles->read($path); } $compressor = new GZIP(); $source = $compressor->decompress($source); @@ -208,7 +208,7 @@ class Get extends Action } if (!empty($rangeHeader)) { - $response->send($deviceForFiles->read($path, $start, ($end - $start + 1))); + $response->send((string) $deviceForFiles->read($path, $start, ($end - $start + 1))); return; } @@ -216,7 +216,7 @@ class Get extends Action if ($size > APP_STORAGE_READ_BUFFER) { for ($i = 0; $i < ceil($size / MAX_OUTPUT_CHUNK_SIZE); $i++) { $response->chunk( - $deviceForFiles->read( + (string) $deviceForFiles->read( $path, ($i * MAX_OUTPUT_CHUNK_SIZE), min(MAX_OUTPUT_CHUNK_SIZE, $size - ($i * MAX_OUTPUT_CHUNK_SIZE)) @@ -225,7 +225,7 @@ class Get extends Action ); } } else { - $response->send($deviceForFiles->read($path)); + $response->send((string) $deviceForFiles->read($path)); } } } diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 3f92ec7b93..6e91c554c3 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -1008,7 +1008,7 @@ class Messaging extends Action } if ($deviceForFiles->getType() !== DeviceType::Local) { - $deviceForFiles->transfer($path, $path, $this->getLocalDevice($project)); + $deviceForFiles->copy($path, $path, $this->getLocalDevice($project)); } $attachment = new Attachment(