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 0000000000..d8fc92d022 Binary files /dev/null and b/tests/resources/test.wasm differ