Skip to content

Commit dc7129c

Browse files
authored
Merge pull request #68 from urbantrout/develop-v4
Fix progress URLs and send application/json response
2 parents f61eb30 + 761d07c commit dc7129c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/controllers/DefaultController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212

1313
use Craft;
1414
use craft\errors\AssetDisallowedExtensionException;
15-
use craft\helpers\Json as JsonHelper;
1615
use craft\helpers\Path as PathHelper;
1716
use craft\web\Controller;
17+
use craft\web\Response;
1818
use nystudio107\transcoder\Transcoder;
1919
use yii\base\ExitException;
2020
use yii\web\BadRequestHttpException;
21+
2122
use function count;
2223
use function is_array;
2324

@@ -28,7 +29,6 @@
2829
*/
2930
class DefaultController extends Controller
3031
{
31-
3232
// Protected Properties
3333
// =========================================================================
3434

@@ -100,9 +100,9 @@ public function actionDownloadFile($url): void
100100
*
101101
* @param $filename
102102
*
103-
* @return string
103+
* @return Response
104104
*/
105-
public function actionProgress($filename): string
105+
public function actionProgress($filename): Response
106106
{
107107
$result = [];
108108
$progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename . '.progress';
@@ -173,6 +173,6 @@ public function actionProgress($filename): string
173173
}
174174
}
175175

176-
return JsonHelper::encode($result);
176+
return $this->asJson($result);
177177
}
178178
}

src/services/Transcode.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,13 @@ public function getFileInfo(Asset|string $filePath, bool $summary = false): ?arr
536536
/**
537537
* Get the name of a video file from a path and options
538538
*
539-
* @param string $filePath
539+
* @param Asset|string $filePath
540540
* @param array $videoOptions
541541
*
542542
* @return string
543543
* @throws InvalidConfigException
544544
*/
545-
public function getVideoFilename(string $filePath, array $videoOptions): string
545+
public function getVideoFilename(Asset|string $filePath, array $videoOptions): string
546546
{
547547
$settings = Transcoder::$plugin->getSettings();
548548
$videoOptions = $this->coalesceOptions('defaultVideoOptions', $videoOptions);
@@ -559,13 +559,13 @@ public function getVideoFilename(string $filePath, array $videoOptions): string
559559
/**
560560
* Get the name of an audio file from a path and options
561561
*
562-
* @param string $filePath
562+
* @param Asset|string $filePath
563563
* @param array $audioOptions
564564
*
565565
* @return string
566566
* @throws InvalidConfigException
567567
*/
568-
public function getAudioFilename(string $filePath, array $audioOptions): string
568+
public function getAudioFilename(Asset|string $filePath, array $audioOptions): string
569569
{
570570
$settings = Transcoder::$plugin->getSettings();
571571
$audioOptions = $this->coalesceOptions('defaultAudioOptions', $audioOptions);
@@ -582,13 +582,13 @@ public function getAudioFilename(string $filePath, array $audioOptions): string
582582
/**
583583
* Get the name of a gif video file from a path and options
584584
*
585-
* @param string $filePath
585+
* @param Asset|string $filePath
586586
* @param array $gifOptions
587587
*
588588
* @return string
589589
* @throws InvalidConfigException
590590
*/
591-
public function getGifFilename(string $filePath, array $gifOptions): string
591+
public function getGifFilename(Asset|string $filePath, array $gifOptions): string
592592
{
593593
$settings = Transcoder::$plugin->getSettings();
594594
$gifOptions = $this->coalesceOptions('defaultGifOptions', $gifOptions);
@@ -721,13 +721,13 @@ public function getGifUrl(Asset|string $filePath, array $gifOptions): string|fal
721721
/**
722722
* Get the name of a file from a path and options
723723
*
724-
* @param string $filePath
724+
* @param Asset|string $filePath
725725
* @param array $options
726726
*
727727
* @return string
728728
* @throws InvalidConfigException
729729
*/
730-
protected function getFilename(string $filePath, array $options): string
730+
protected function getFilename(Asset|string $filePath, array $options): string
731731
{
732732
$settings = Transcoder::$plugin->getSettings();
733733
$filePath = $this->getAssetPath($filePath);

0 commit comments

Comments
 (0)