Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist \
`if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi`

FROM appwrite/base:0.10.4 AS final
FROM appwrite/base:0.10.5 AS final

LABEL maintainer="[email protected]"

Expand All @@ -28,8 +28,6 @@ RUN \
apk add boost boost-dev; \
fi

RUN apk add libwebp

WORKDIR /usr/src/code

COPY --from=composer /usr/local/src/vendor /usr/src/code/vendor
Expand Down
63 changes: 60 additions & 3 deletions tests/e2e/Services/Storage/StorageBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testCreateBucketFile(): array
'name' => 'Test Bucket',
'fileSecurity' => true,
'maximumFileSize' => 2000000, //2MB
'allowedFileExtensions' => ['jpg', 'png', 'jfif'],
'allowedFileExtensions' => ['jpg', 'png', 'jfif', 'webp'],
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
Expand Down Expand Up @@ -263,7 +263,39 @@ public function testCreateBucketFile(): array
$this->assertEquals(400, $res['headers']['status-code']);
$this->assertEquals(Exception::STORAGE_INVALID_APPWRITE_ID, $res['body']['type']);

return ['bucketId' => $bucketId, 'fileId' => $file['body']['$id'], 'largeFileId' => $largeFile['body']['$id'], 'largeBucketId' => $bucket2['body']['$id']];
/**
* Test for SUCCESS - Upload and view webp image
*/
$webpFile = $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/image.webp'), 'image/webp', 'image.webp'),
'permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
]);
$this->assertEquals(201, $webpFile['headers']['status-code']);
$this->assertNotEmpty($webpFile['body']['$id']);
$this->assertEquals('image.webp', $webpFile['body']['name']);
$this->assertEquals('image/webp', $webpFile['body']['mimeType']);

$webpFileId = $webpFile['body']['$id'];

// View webp file
$webpView = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $webpFileId . '/view', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));

$this->assertEquals(200, $webpView['headers']['status-code']);
$this->assertEquals('image/webp', $webpView['headers']['content-type']);
$this->assertNotEmpty($webpView['body']);

return ['bucketId' => $bucketId, 'fileId' => $file['body']['$id'], 'largeFileId' => $largeFile['body']['$id'], 'largeBucketId' => $bucket2['body']['$id'], 'webpFileId' => $webpFileId];
}

public function testCreateBucketFileZstdCompression(): array
Expand Down Expand Up @@ -416,7 +448,7 @@ public function testListBucketFiles(array $data): array
],
]);
$this->assertEquals(200, $files['headers']['status-code']);
$this->assertEquals(0, count($files['body']['files']));
$this->assertEquals(1, count($files['body']['files']));

$files = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $data['bucketId'] . '/files', array_merge([
'content-type' => 'application/json',
Expand Down Expand Up @@ -869,6 +901,31 @@ public function testUpdateBucketFile(array $data): array
return $data;
}

/**
* @depends testCreateBucketFile
*/
public function testFilePreview(array $data): array
{
$bucketId = $data['bucketId'];
$fileId = $data['fileId'];

// Preview PNG as webp
$preview = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId . '/preview', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'width' => 300,
'height' => 300,
'output' => 'webp',
]);

$this->assertEquals(200, $preview['headers']['status-code']);
$this->assertEquals('image/webp', $preview['headers']['content-type']);
$this->assertNotEmpty($preview['body']);

return $data;
}

/**
* @depends testUpdateBucketFile
*/
Expand Down
Binary file added tests/resources/image.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.