Commit 6a77a9d2 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix(s3): remove proxy, set objects acl to public-read, and serve files using their public urls

parent de099ac6
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ class Media extends BaseConfig
        'debug'             => false,
        'pathStyleEndpoint' => false,
        'keyPrefix'         => '',
        'serveWithRedirect' => false,
    ];

    /**

modules/Media/Config/Routes.php

deleted100644 → 0
+0 −24
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

use CodeIgniter\Router\RouteCollection;

/**
 * @copyright  2023 Ad Aures
 * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
 * @link       https://castopod.org/
 */

/** @var RouteCollection $routes */

$routes->head('static/(:any)', 'MediaController::serve/$1', [
    'as'        => 'media-serve',
    'namespace' => 'Modules\Media\Controllers',
    'filter'    => 'allow-cors',
]);
$routes->get('static/(:any)', 'MediaController::serve/$1', [
    'as'        => 'media-serve',
    'namespace' => 'Modules\Media\Controllers',
    'filter'    => 'allow-cors',
]);
+0 −26
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

/**
 * @copyright  2020 Ad Aures
 * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
 * @link       https://castopod.org/
 */

namespace Modules\Media\Controllers;

use CodeIgniter\Controller;
use CodeIgniter\HTTP\Response;
use Modules\Media\FileManagers\FileManagerInterface;

class MediaController extends Controller
{
    public function serve(string ...$key): Response
    {
        /** @var FileManagerInterface $fileManager */
        $fileManager = service('file_manager');

        return $fileManager->serve(implode('/', $key));
    }
}
+0 −6
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Modules\Media\FileManagers;

use CodeIgniter\Files\File;
use CodeIgniter\HTTP\Response;
use Exception;
use Modules\Media\Config\Media as MediaConfig;

@@ -131,11 +130,6 @@ class FS implements FileManagerInterface
        return is_really_writable($this->media_path_absolute());
    }

    public function serve(string $key): Response
    {
        return redirect()->to($this->getUrl($key));
    }

    /**
     * Prefixes the absolute storage directory to the media path of a given uri
     *
+0 −3
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Modules\Media\FileManagers;

use CodeIgniter\Files\File;
use CodeIgniter\HTTP\Response;

interface FileManagerInterface
{
@@ -28,6 +27,4 @@ interface FileManagerInterface
    public function deleteAll(string $prefix, string $pattern = '*'): bool;

    public function isHealthy(): bool;

    public function serve(string $key): Response;
}
Loading