|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the XabbuhPandaBundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Xabbuh\PandaBundle\Command; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Command for upload video files into a Panda cloud. |
|
21
|
|
|
* |
|
22
|
|
|
* @author Christian Flothmann <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class UploadVideoCommand extends CloudCommand |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* {@inheritDoc} |
|
28
|
|
|
*/ |
|
29
|
7 |
|
protected function configure() |
|
30
|
|
|
{ |
|
31
|
7 |
|
$this->setName('panda:video:upload'); |
|
32
|
7 |
|
$this->setDescription('Upload a video'); |
|
33
|
7 |
|
$this->addOption( |
|
34
|
7 |
|
'profile', |
|
35
|
7 |
|
null, |
|
36
|
7 |
|
InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, |
|
37
|
7 |
|
'A profile to be used to encode the video, use it several times to use more than one profile' |
|
38
|
|
|
); |
|
39
|
7 |
|
$this->addOption( |
|
40
|
7 |
|
'path-format', |
|
41
|
7 |
|
null, |
|
42
|
7 |
|
InputOption::VALUE_REQUIRED, |
|
43
|
7 |
|
'Custom path format' |
|
44
|
|
|
); |
|
45
|
7 |
|
$this->addOption( |
|
46
|
7 |
|
'payload', |
|
47
|
7 |
|
null, |
|
48
|
7 |
|
InputOption::VALUE_REQUIRED, |
|
49
|
7 |
|
'An arbitrary string stored with the video' |
|
50
|
|
|
); |
|
51
|
7 |
|
$this->addArgument( |
|
52
|
7 |
|
'filename', |
|
53
|
7 |
|
InputArgument::REQUIRED, |
|
54
|
7 |
|
'The file being uploaded' |
|
55
|
|
|
); |
|
56
|
|
|
|
|
57
|
7 |
|
parent::configure(); |
|
58
|
7 |
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* {@inheritDoc} |
|
62
|
|
|
*/ |
|
63
|
6 |
|
protected function doExecuteCommand(InputInterface $input, OutputInterface $output) |
|
64
|
|
|
{ |
|
65
|
6 |
|
$profiles = $input->getOption('profile'); |
|
66
|
6 |
|
$pathFormat = $input->getOption('path-format'); |
|
67
|
6 |
|
$payload = $input->getOption('payload'); |
|
68
|
|
|
|
|
69
|
6 |
|
$output->writeln('Starting file upload...'); |
|
70
|
6 |
|
$this->getCloud($input)->encodeVideoFile( |
|
71
|
6 |
|
$input->getArgument('filename'), |
|
72
|
6 |
|
$profiles, |
|
73
|
6 |
|
$pathFormat, |
|
74
|
6 |
|
$payload |
|
75
|
|
|
); |
|
76
|
5 |
|
$output->writeln('<info>File uploaded successfully.</info>'); |
|
77
|
5 |
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|