From ed01b5abe3997d77dce56bbe24f68e4c8fb9ec70 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 1 Jun 2023 05:44:19 +0000 Subject: [PATCH] update file name --- app/controllers/api/storage.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index b936fc6b2f..5ba2640f60 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -1268,13 +1268,14 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId') ->label('sdk.response.model', Response::MODEL_FILE) ->param('bucketId', '', new UID(), 'Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).') ->param('fileId', '', new UID(), 'File unique ID.') + ->param('name', null, new Text(255), 'Name of the file', true) ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE]), 'An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).', true) ->inject('response') ->inject('dbForProject') ->inject('user') ->inject('mode') ->inject('events') - ->action(function (string $bucketId, string $fileId, ?array $permissions, Response $response, Database $dbForProject, Document $user, string $mode, Event $events) { + ->action(function (string $bucketId, string $fileId, ?string $name, ?array $permissions, Response $response, Database $dbForProject, Document $user, string $mode, Event $events) { $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); @@ -1330,6 +1331,10 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId') $file->setAttribute('$permissions', $permissions); + if (!is_null($name)) { + $file->setAttribute('name', $name); + } + if ($fileSecurity && !$valid) { try { $file = $dbForProject->updateDocument('bucket_' . $bucket->getInternalId(), $fileId, $file);