From 841bfd646a4447aa059a197d4c1a6bd13cb39949 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 23 Nov 2025 22:24:49 +0000 Subject: [PATCH] Add WebAssembly support and update MIME types Co-authored-by: eldad --- app/config/storage/mimes.php | 3 + tests/e2e/Services/Storage/StorageBase.php | 67 +++++++++++++++++++++ tests/resources/test.wasm | Bin 0 -> 8 bytes 3 files changed, 70 insertions(+) create mode 100644 tests/resources/test.wasm diff --git a/app/config/storage/mimes.php b/app/config/storage/mimes.php index 5c1752ca51..4d6dd47f47 100644 --- a/app/config/storage/mimes.php +++ b/app/config/storage/mimes.php @@ -68,4 +68,7 @@ return [ // Adobe PDF "application/pdf", + + // WebAssembly + "application/wasm", ]; diff --git a/tests/e2e/Services/Storage/StorageBase.php b/tests/e2e/Services/Storage/StorageBase.php index 2b2c884283..a1b7eae7ab 100644 --- a/tests/e2e/Services/Storage/StorageBase.php +++ b/tests/e2e/Services/Storage/StorageBase.php @@ -877,4 +877,71 @@ trait StorageBase return $data; } + + public function testWasmFileMimeType(): void + { + /** + * Test for SUCCESS - WASM file MIME type + */ + $bucket = $this->client->call(Client::METHOD_POST, '/storage/buckets', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], [ + 'bucketId' => ID::unique(), + 'name' => 'Test Bucket for WASM', + 'fileSecurity' => true, + 'permissions' => [ + Permission::read(Role::any()), + Permission::create(Role::any()), + Permission::update(Role::any()), + Permission::delete(Role::any()), + ], + ]); + $this->assertEquals(201, $bucket['headers']['status-code']); + $this->assertNotEmpty($bucket['body']['$id']); + + $bucketId = $bucket['body']['$id']; + + // Upload WASM file + $file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', array_merge([ + 'content-type' => 'multipart/form-data', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'fileId' => ID::unique(), + 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/test.wasm'), 'application/wasm', 'test.wasm'), + 'permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + Permission::delete(Role::any()), + ], + ]); + + $this->assertEquals(201, $file['headers']['status-code']); + $this->assertNotEmpty($file['body']['$id']); + $this->assertEquals('test.wasm', $file['body']['name']); + $this->assertEquals('application/wasm', $file['body']['mimeType']); + + $fileId = $file['body']['$id']; + + // Test file view endpoint returns correct MIME type + $view = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId . '/view', array_merge([ + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $view['headers']['status-code']); + $this->assertEquals('application/wasm', $view['headers']['content-type']); + + // Clean up + $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucketId . '/files/' . $fileId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucketId, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]); + } } diff --git a/tests/resources/test.wasm b/tests/resources/test.wasm new file mode 100644 index 0000000000000000000000000000000000000000..d8fc92d022fbf4d1072da17bc8e0840054b51ddc GIT binary patch literal 8 PcmZQbEY4+QU|;|M2ZjMd literal 0 HcmV?d00001