Changed downloading YouTube posts in backend

Trying to download YouTube posts by visiting backend directly results in
a redirect to YouTube instead of showing an ugly error.
This commit is contained in:
Marcin Kurczewski 2014-11-19 19:46:40 +01:00
parent 8bd4ae27c2
commit c6fe7a4320

View file

@ -2,6 +2,7 @@
namespace Szurubooru\Controllers; namespace Szurubooru\Controllers;
use Szurubooru\Config; use Szurubooru\Config;
use Szurubooru\Dao\PublicFileDao; use Szurubooru\Dao\PublicFileDao;
use Szurubooru\Entities\Post;
use Szurubooru\Helpers\MimeHelper; use Szurubooru\Helpers\MimeHelper;
use Szurubooru\Router; use Szurubooru\Router;
use Szurubooru\Services\NetworkingService; use Szurubooru\Services\NetworkingService;
@ -45,6 +46,12 @@ final class PostContentController extends AbstractController
$post->getName(), $post->getName(),
strtolower(MimeHelper::getExtension($post->getContentMimeType()))); strtolower(MimeHelper::getExtension($post->getContentMimeType())));
if ($post->getContentType() === Post::POST_TYPE_YOUTUBE)
{
$this->networkingService->nonCachedRedirect($post->getOriginalFileName());
return;
}
$this->networkingService->serveFile($this->fileDao->getFullPath($post->getContentPath()), $customFileName); $this->networkingService->serveFile($this->fileDao->getFullPath($post->getContentPath()), $customFileName);
} }