Skip to content

Commit

Permalink
fix assetId default value
Browse files Browse the repository at this point in the history
  • Loading branch information
labudzinski committed Dec 7, 2023
1 parent 18d1bb4 commit b027f8c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Helper/UploadHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function createSession(Request $request, int $partSize): DatahubUploadSes
$fileName = Service::getValidKey($fileName, 'asset');

$fileSize = (int) $request->get('filesize');
$assetId = $request->request->get('asset_id', null);
$assetId = $request->request->get('asset_id', 0);

if (!isset($fileName, $fileSize)) {
throw new InvalidParameterException(['filesize', 'file_name']);
Expand All @@ -82,7 +82,7 @@ public function createSession(Request $request, int $partSize): DatahubUploadSes
$parentId = $request->request->get('parentId');
$parentId = $this->getParent($parentId, $assetId);

if (null !== $assetId) {
if (0 !== $assetId) {
$asset = Asset::getById($assetId);
if ($asset instanceof Asset) {
if (!$asset->isAllowed('allowOverwrite', $this->user)) {
Expand Down Expand Up @@ -234,8 +234,7 @@ private function getParent(?int $parentId, ?int $assetId): int
if (!$parentAsset->isAllowed('create', $this->user) && !$this->authManager->isAllowed($parentAsset, 'create', $this->user)) {
throw new AccessDeniedHttpException('Missing the permission to create new assets in the folder: '.$parentAsset->getRealFullPath());
}

if (null !== $assetId) {
if (null !== $assetId && $assetId > 0) {
$asset = Asset::getById($assetId);
if (!$asset instanceof Asset) {
throw new NotFoundException('Asset does not exist');
Expand Down

0 comments on commit b027f8c

Please sign in to comment.