Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sugeng-sulistiyawan committed Oct 25, 2024
1 parent ba27084 commit 43ade13
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
10 changes: 1 addition & 9 deletions src/actions/FileAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
*/
class FileAction extends Action
{
const FILENAME_SEPARATOR = 'fname-';

/**
* @var string filesystem config component (fs)
*/
Expand All @@ -54,9 +52,7 @@ public function run($data = null)
$filesystem = Yii::$app->get($this->component);

try {
[$dataEncrypt, $filename] = explode(self::FILENAME_SEPARATOR, $data);

$params = Json::decode($filesystem->/** @scrutinizer ignore-call */decrypt($dataEncrypt));
$params = Json::decode($filesystem->/** @scrutinizer ignore-call */decrypt($data));

$now = (int) (new DateTimeImmutable())->getTimestamp();
$expires = (int) $params['expires'];
Expand All @@ -66,10 +62,6 @@ public function run($data = null)
}

$attachmentName = (string) pathinfo($params['path'], PATHINFO_BASENAME);
if ($filename !== $attachmentName) {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
}

$content = $filesystem->read($params['path']);
$mimeType = $filesystem->mimeType($params['path']);
} catch (\Throwable $th) {
Expand Down
4 changes: 1 addition & 3 deletions src/traits/UrlGeneratorAdapterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use DateTimeInterface;
use diecoding\flysystem\AbstractComponent;
use diecoding\flysystem\actions\FileAction;
use League\Flysystem\Config;
use League\Flysystem\PathPrefixer;
use yii\helpers\Json;
Expand Down Expand Up @@ -61,8 +60,7 @@ public function temporaryUrl(string $path, DateTimeInterface $expiresAt, /** @sc

private function generateUrlAction(array $params): string
{
$attachmentName = (string) pathinfo($params['path'], PATHINFO_BASENAME);
$data = $this->component->/** @scrutinizer ignore-call */encrypt(Json::encode($params)) . FileAction::FILENAME_SEPARATOR . $attachmentName;
$data = $this->component->/** @scrutinizer ignore-call */encrypt(Json::encode($params));

return Url::toRoute([$this->component->action, 'data' => $data], true);
}
Expand Down

0 comments on commit 43ade13

Please sign in to comment.