plugin/drop-zone/Controller/API/DropzoneController.php
public function downloadAction(Document $document)
    {
        $this->checkDocumentAccess($document);
        $data = $document->getData();

        $response = new StreamedResponse();
        $path = $this->filesDir.DIRECTORY_SEPARATOR.$data['url'];
        $response->setCallBack(
            function () use ($path) {
                readfile($path);
            }
        );
        $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename='.$data['name']);
        $response->headers->set('Content-Type', $data['mimeType']);
        $response->headers->set('Connection', 'close');

        $this->eventDispatcher->dispatch('log', new LogDocumentOpenEvent($document->getDrop()->getDropzone(), $document->getDrop(), $document));

        return $response->send();
    }
public function downloadAction(Document $document)
    {
        $this->checkDocumentAccess($document);
        $data = $document->getData();

        $response = new StreamedResponse();
        $path = $this->filesDir.DIRECTORY_SEPARATOR.$data['url'];
        $response->setCallBack(
            function () use ($path) {
                readfile($path);
            }
        );
        $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename='.$data['name']);
        $response->headers->set('Content-Type', $data['mimeType']);
        $response->headers->set('Connection', 'close');

        $this->eventDispatcher->dispatch('log', new LogDocumentOpenEvent($document->getDrop()->getDropzone(), $document->getDrop(), $document));

        return $response->send();
    }
public function downloadAction ( Document $ document ) { $ this -> checkDocumentAccess ( $ document ) ; $ data = $ document -> getData ( ) ; $ response = new StreamedResponse ( ) ; $ path = $ this -> filesDir . DIRECTORY_SEPARATOR . $ data [ 'url' ] ; $ response -> setCallBack ( function ( ) use ( $ path ) { readfile ( $ path ) ; } ) ; $ response -> headers -> set ( 'Content-Transfer-Encoding' , 'octet-stream' ) ; $ response -> headers -> set ( 'Content-Type' , 'application/force-download' ) ; $ response -> headers -> set ( 'Content-Disposition' , 'attachment; filename=' . $ data [ 'name' ] ) ; $ response -> headers -> set ( 'Content-Type' , $ data [ 'mimeType' ] ) ; $ response -> headers -> set ( 'Connection' , 'close' ) ; $ this -> eventDispatcher -> dispatch ( 'log' , new LogDocumentOpenEvent ( $ document -> getDrop ( ) -> getDropzone ( ) , $ document -> getDrop ( ) , $ document ) ) ; return $ response -> send ( ) ; }
Downloads a document.

@EXT\Route("/{document}/download", name="claro_dropzone_document_download")
@EXT\Method("GET")
@EXT\ParamConverter(
"document",
class="ClarolineDropZoneBundle:Document",
options={"mapping": {"document": "uuid"}}
)

@param Document $document

@return StreamedResponse
Downloads a document .