diff --git a/src/Appwrite/Utopia/Response/Model/ResourceToken.php b/src/Appwrite/Utopia/Response/Model/ResourceToken.php index f3bbc5fccc..8f44a55b56 100644 --- a/src/Appwrite/Utopia/Response/Model/ResourceToken.php +++ b/src/Appwrite/Utopia/Response/Model/ResourceToken.php @@ -34,6 +34,12 @@ class ResourceToken extends Model 'default' => '', 'example' => '1:1', ]) + ->addRule('resourceType', [ + 'type' => self::TYPE_STRING, + 'description' => 'Resource type.', + 'default' => '', + 'example' => 'file', + ]) ->addRule('expire', [ 'type' => self::TYPE_DATETIME, 'description' => 'Token expiration date in ISO 8601 format.', diff --git a/tests/e2e/Services/Storage/StorageBase.php b/tests/e2e/Services/Storage/StorageBase.php index c4a15585eb..4ac6ff6e64 100644 --- a/tests/e2e/Services/Storage/StorageBase.php +++ b/tests/e2e/Services/Storage/StorageBase.php @@ -13,6 +13,9 @@ use Utopia\Database\Validator\Datetime as DatetimeValidator; trait StorageBase { + /** + * @group fileTokens + */ public function testCreateBucketFile(): array { /** @@ -741,6 +744,25 @@ trait StorageBase return $data; } + /** + * @group fileTokens + * @depends testCreateBucketFile + */ + public function testCreateFileToken(array $data): array + { + $bucketId = $data['bucketId']; + $fileId = $data['fileId']; + + $res = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files/' . $fileId . '/tokens', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(201, $res['headers']['status-code']); + $this->assertEquals('file', $res['body']['resourceType']); + return $data; + } + /** * @depends testCreateBucketFileZstdCompression */