mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
Add after create success hook in file creation process
This commit is contained in:
parent
07135956df
commit
03ccca2c35
1 changed files with 16 additions and 0 deletions
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue