From 03ccca2c359b8996a2c57c6f74c5ad288bc70ff4 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 31 Dec 2025 13:05:41 +0000 Subject: [PATCH] Add after create success hook in file creation process --- .../Storage/Http/Buckets/Files/Create.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Create.php b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Create.php index b2d9af5a08..ed5c23b6c1 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Create.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Create.php @@ -385,6 +385,9 @@ class Create extends Action } $file = Authorization::skip(fn () => $dbForProject->updateDocument('bucket_' . $bucket->getSequence(), $fileId, $file)); } + + // Trigger after create success hook + $this->afterCreateSuccess($file); } else { if ($file->isEmpty()) { $doc = new Document([ @@ -448,4 +451,17 @@ class Create extends Action ->setStatusCode(Response::STATUS_CODE_CREATED) ->dynamic($file, Response::MODEL_FILE); } + + /** + * Hook to run after file is created successfully + * + * @param Document $file + * @return void + */ + protected function afterCreateSuccess(Document $file) + { + if (!($file instanceof Document)) { + throw new Exception('file must be an instance of document'); + } + } }