1
0
Fork 0
mirror of synced 2024-07-05 14:40:42 +12:00

Merge branch 'feat-storage-buckets' into feat-large-file

This commit is contained in:
Damodar Lohani 2021-10-19 12:41:51 +05:45
commit 0f61377b58
3 changed files with 21 additions and 4 deletions

View file

@ -783,8 +783,25 @@ trait RealtimeBase
/** /**
* Test File Create * Test File Create
* TODO Buckets Channels
*/ */
$file = $this->client->call(Client::METHOD_POST, '/storage/files', array_merge([ $bucket = $this->client->call(Client::METHOD_POST, '/storage/buckets', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], $this->getHeaders()), [
'bucketId' => 'unique()',
'name' => 'Test Bucket',
'permission' => 'file',
'read' => ['role:all'],
'write' => ['role:all'],
]);
$this->assertEquals(201, $bucket['headers']['status-code']);
$this->assertNotEmpty($bucket['body']['$id']);
$bucketId = $bucket['body']['$id'];
$file = $this->client->call(Client::METHOD_POST, '/storage/buckets/'.$bucketId.'/files', array_merge([
'content-type' => 'multipart/form-data', 'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
@ -813,7 +830,7 @@ trait RealtimeBase
/** /**
* Test File Update * Test File Update
*/ */
$this->client->call(Client::METHOD_PUT, '/storage/files/' . $data['fileId'], array_merge([ $this->client->call(Client::METHOD_PUT, '/storage/buckets/'.$bucketId.'files/' . $data['fileId'], array_merge([
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
@ -837,7 +854,7 @@ trait RealtimeBase
/** /**
* Test File Delete * Test File Delete
*/ */
$this->client->call(Client::METHOD_DELETE, '/storage/files/' . $data['fileId'], array_merge([ $this->client->call(Client::METHOD_DELETE, '/storage/buckets/'. $bucketId . 'files/' . $data['fileId'], array_merge([
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders())); ], $this->getHeaders()));

View file

@ -39,7 +39,6 @@ class StorageCustomClientTest extends Scope
], $this->getHeaders()), [ ], $this->getHeaders()), [
'fileId' => 'unique()', 'fileId' => 'unique()',
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'), 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'),
'folderId' => 'xyz',
]); ]);
$this->assertEquals($file['headers']['status-code'], 201); $this->assertEquals($file['headers']['status-code'], 201);

View file

@ -246,6 +246,7 @@ trait WebhooksBase
]), [ ]), [
'bucketId' => 'unique()', 'bucketId' => 'unique()',
'name' => 'Test Bucket', 'name' => 'Test Bucket',
'permission' => 'bucket',
'read' => ['role:all'], 'read' => ['role:all'],
'write' => ['role:all'] 'write' => ['role:all']
]); ]);