-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
databox basket sync expose multipart
- Loading branch information
Showing
6 changed files
with
214 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
lib/php/storage-bundle/Controller/MultipartUploadCancelAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Alchemy\StorageBundle\Controller; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Alchemy\StorageBundle\Upload\UploadManager; | ||
use Alchemy\StorageBundle\Entity\MultipartUpload; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
|
||
class MultipartUploadCancelAction extends AbstractController | ||
{ | ||
public function __construct(private UploadManager $uploadManager, private EntityManagerInterface $em,) | ||
{ | ||
} | ||
|
||
public function __invoke(MultipartUpload $data, Request $request) | ||
{ | ||
try { | ||
$this->uploadManager->cancelMultipartUpload($data->getPath(), $data->getUploadId()); | ||
} catch (\Exception $e) { | ||
|
||
} | ||
|
||
$this->em->remove($data); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
lib/php/storage-bundle/Controller/MultipartUploadCompleteAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Alchemy\StorageBundle\Controller; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Alchemy\StorageBundle\Upload\UploadManager; | ||
use Alchemy\StorageBundle\Entity\MultipartUpload; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | ||
|
||
final class MultipartUploadCompleteAction extends AbstractController | ||
{ | ||
public function __construct(private UploadManager $uploadManager, private EntityManagerInterface $em,) | ||
{ | ||
} | ||
|
||
public function __invoke(MultipartUpload $data, Request $request) | ||
{ | ||
$parts = $request->request->all('parts'); | ||
|
||
if (empty($parts)) { | ||
throw new BadRequestHttpException('Missing parts'); | ||
} | ||
|
||
$res = $this->uploadManager->markComplete($data->getUploadId(), $data->getPath(), (array) $parts); | ||
|
||
$data->setComplete(true); | ||
$this->em->persist($data); | ||
$this->em->flush(); | ||
|
||
return new JsonResponse([ | ||
'path' => $res['Key'], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters