improve get file token

This commit is contained in:
Damodar Lohani
2023-12-27 00:03:16 +00:00
parent 92c2e26f3a
commit 23d0aae23b
+7 -1
View File
@@ -1680,7 +1680,13 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/tokens/:tokenId')
throw new Exception(Exception::STORAGE_FILE_NOT_FOUND);
}
$response->dynamic($file, Response::MODEL_FILE_TOKEN);
$token = $dbForProject->getDocument('fileTokens', $tokenId);
if($token->isEmpty() || $token->getAttribute('bucketInternalId') != $bucket->getInternalId() || $token->getAttribute('fileInternalId') != $file->getInternalId()) {
throw new Exception(Exception::STORAGE_FILE_TOKEN_NOT_FOUND);
}
$response->dynamic($token, Response::MODEL_FILE_TOKEN);
});
App::put('/v1/storage/buckets/:bucketId/files/:fileId/tokens/:tokenId')