Created
January 31, 2019 20:06
-
-
Save 0GiS0/ff6884d23992bb9173da21ea012580a9 to your computer and use it in GitHub Desktop.
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
<?php | |
namespace App\Controller; | |
use App\Service\BlobService; | |
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
use Symfony\Component\Routing\Annotation\Route; | |
class BlobsController extends AbstractController | |
{ | |
/** | |
* @Route("/", name="blobs") | |
*/ | |
public function index(BlobService $storage) | |
{ | |
return $this->render('blobs/index.html.twig', [ | |
'controller_name' => 'BlobsController', | |
'blobs' => $storage->allBlobs(), | |
'containers' => $storage->allContainers(), | |
]); | |
} | |
/** | |
* @Route("/upload/image", methods={"POST"}) | |
*/ | |
public function create(Request $request, BlobService $storage) | |
{ | |
$file = $request->files->get('newFile'); | |
if (empty($file)) { | |
return new Response("No file specified", Response::HTTP_UNPROCESSABLE_ENTITY, ['content-type' => 'text/plain']); | |
} | |
$storage->upload($file); | |
return $this->redirectToRoute('blobs'); | |
} | |
/** | |
* @Route("/delete/{blobName}") | |
*/ | |
public function deleteBlob($blobName, BlobService $storage) | |
{ | |
$storage->delete($blobName); | |
return $this->redirectToRoute('blobs'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment