Merge pull request #11054 from appwrite/feat-file-create-after-success-hook

Feat: add after success hook for file creation endpoint
This commit is contained in:
Damodar Lohani 2026-01-08 11:31:14 +05:45 committed by GitHub
commit 27aee1fb88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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');
}
}
}