Skip to content

Commit 2d9940b

Browse files
committed
* Refactoring
1 parent 5075d7a commit 2d9940b

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @package Transcoder
2121
* @since 1.0.0
2222
*/
23-
class TranscoderController extends Controller
23+
class DefaultController extends Controller
2424
{
2525

2626
// Protected Properties
@@ -50,5 +50,6 @@ public function actionDownloadFile()
5050
null,
5151
['inline' => false]
5252
);
53+
Craft::$app->end();
5354
}
5455
}

src/services/Transcoder.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ protected function getAssetPath($filePath): string
203203
{
204204
// If we're passed an Asset, extract the path from it
205205
if (is_object($filePath) && ($filePath instanceof Asset)) {
206-
$asset = (Asset)$filePath;
206+
$asset = $filePath;
207207
$assetVolume = $asset->getVolume();
208208

209209
if (!(($assetVolume instanceof Local) || is_subclass_of($assetVolume, Local::class))) {
@@ -212,8 +212,10 @@ protected function getAssetPath($filePath): string
212212
);
213213
}
214214

215-
$sourcePath = $assetVolume->path;
216-
$folderPath = $asset->getFolder()->path;
215+
$sourcePath = rtrim($assetVolume->path, DIRECTORY_SEPARATOR);
216+
$sourcePath .= strlen($sourcePath) ? DIRECTORY_SEPARATOR : '';
217+
$folderPath = rtrim($asset->getFolder()->path, DIRECTORY_SEPARATOR);
218+
$folderPath .= strlen($folderPath) ? DIRECTORY_SEPARATOR : '';
217219

218220
$filePath = $sourcePath.$folderPath.$asset->filename;
219221
}

src/variables/TranscoderVariable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getDownloadUrl($url): string
7373
$urlParams = [
7474
'url' => urlencode($url),
7575
];
76-
$result = UrlHelper::actionUrl('transcoder/downloadFile', $urlParams);
76+
$result = UrlHelper::actionUrl('transcoder/default/download-file', $urlParams);
7777
}
7878

7979
return $result;

0 commit comments

Comments
 (0)