Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
149
Issues
149
List
Boards
Labels
Service Desk
Milestones
Merge Requests
49
Merge Requests
49
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
5789a5e2
Commit
5789a5e2
authored
11 minutes ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): spec tests for client upload
parent
600ab188
feat/client-uploader
1 merge request
!263
(feat): Client uploader
Pipeline
#70279474
passed with stages
in 8 minutes and 3 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
22 deletions
+139
-22
ClientUploadLease.php
Core/Media/ClientUpload/ClientUploadLease.php
+7
-0
FFMpeg.php
Core/Media/Services/FFMpeg.php
+0
-22
ManagerSpec.php
Spec/Core/Media/ClientUpload/ManagerSpec.php
+81
-0
FFMpegSpec.php
Spec/Core/Media/Services/FFMpegSpec.php
+51
-0
No files found.
Core/Media/ClientUpload/ClientUploadLease.php
View file @
5789a5e2
...
...
@@ -4,6 +4,13 @@ namespace Minds\Core\Media\ClientUpload;
use
Minds\Traits\MagicAttributes
;
/**
* Class ClientUploadLease
* @package Minds\Core\Media\ClientUpload
* @method string getGuid()
* @method string getMediaType()
* @method string getPresignedUrl()
*/
class
ClientUploadLease
{
use
MagicAttributes
;
...
...
This diff is collapsed.
Click to expand it.
Core/Media/Services/FFMpeg.php
View file @
5789a5e2
...
...
@@ -84,28 +84,6 @@ class FFMpeg implements ServiceInterface
*/
public
function
getPresignedUrl
()
{
/* $bucket = 'cinemr';
$formInputs = [ ];
$options = [
//['acl' => 'public-read'],
['bucket' => $bucket],
['eq', '$key', "$this->dir/$this->key/source" ],
];
$expires = '+20 minutes';
$postObject = new \Aws\S3\PostObjectV4(
$this->s3,
$bucket,
$formInputs,
$options,
$expires
);
$formAttributes = $postObject->getFormAttributes();
$formInputs = $postObject->getFormInputs();
var_dump($formAttributes, $formInputs); exit;
*/
$cmd
=
$this
->
s3
->
getCommand
(
'PutObject'
,
[
'Bucket'
=>
'cinemr'
,
'Key'
=>
"
$this->dir
/
$this->key
/source"
,
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Media/ClientUpload/ManagerSpec.php
0 → 100644
View file @
5789a5e2
<?php
namespace
Spec\Minds\Core\Media\ClientUpload
;
use
Minds\Core\Media\ClientUpload\Manager
;
use
Minds\Core\Media\ClientUpload\ClientUploadLease
;
use
Minds\Core\Media\Services\FFMpeg
;
use
Minds\Core\GuidBuilder
;
use
Minds\Core\Entities\Actions\Save
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
class
ManagerSpec
extends
ObjectBehavior
{
private
$ffmpeg
;
private
$guid
;
private
$save
;
function
let
(
FFMpeg
$FFMpeg
,
GuidBuilder
$guid
,
Save
$save
)
{
$this
->
beConstructedWith
(
$FFMpeg
,
$guid
,
$save
);
$this
->
ffmpeg
=
$FFMpeg
;
$this
->
guid
=
$guid
;
$this
->
save
=
$save
;
}
function
it_is_initializable
()
{
$this
->
shouldHaveType
(
Manager
::
class
);
}
function
it_should_return_an_upload_lease
()
{
$this
->
guid
->
build
()
->
willReturn
(
123
);
$this
->
ffmpeg
->
setKey
(
123
)
->
shouldBeCalled
();
$this
->
ffmpeg
->
getPresignedUrl
()
->
willReturn
(
's3-url-here'
);
$lease
=
$this
->
prepare
(
'video'
);
$lease
->
getMediaType
()
->
shouldBe
(
'video'
);
$lease
->
getGuid
()
->
shouldBe
(
123
);
$lease
->
getPresignedUrl
()
->
shouldBe
(
's3-url-here'
);
}
function
it_should_complete_an_upload
(
ClientUploadLease
$lease
)
{
$lease
->
getMediaType
()
->
willReturn
(
'video'
);
$lease
->
getGuid
()
->
willReturn
(
456
);
$this
->
save
->
setEntity
(
Argument
::
that
(
function
(
$video
)
{
return
$video
->
guid
==
456
&&
$video
->
access_id
==
0
;
}))
->
shouldBeCalled
()
->
willReturn
(
$this
->
save
);
$this
->
save
->
save
()
->
shouldBeCalled
();
$this
->
ffmpeg
->
setKey
(
456
)
->
shouldBeCalled
();
$this
->
ffmpeg
->
transcode
()
->
shouldBeCalled
();
$this
->
complete
(
$lease
)
->
shouldReturn
(
true
);
}
}
This diff is collapsed.
Click to expand it.
Spec/Core/Media/Services/FFMpegSpec.php
0 → 100644
View file @
5789a5e2
<?php
namespace
Spec\Minds\Core\Media\Services
;
use
Minds\Core\Media\Services\FFMpeg
;
use
FFMpeg\FFMpeg
as
FFMpegClient
;
use
FFMpeg\FFProbe
as
FFProbeClient
;
use
Minds\Core\Queue\Interfaces\QueueClient
;
use
Psr\Http\Message\RequestInterface
;
use
Aws\S3\S3Client
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
class
FFMpegSpec
extends
ObjectBehavior
{
function
it_is_initializable
()
{
$this
->
shouldHaveType
(
FFMpeg
::
class
);
}
function
it_should_get_a_presigned_urn
(
QueueClient
$queue
,
FFMpegClient
$ffmpeg
,
FFProbeClient
$ffprobe
,
S3Client
$s3
,
\Aws\CommandInterface
$cmd
,
RequestInterface
$request
)
{
$this
->
beConstructedWith
(
$queue
,
$ffmpeg
,
$ffprobe
,
$s3
);
$s3
->
getCommand
(
'PutObject'
,
[
'Bucket'
=>
'cinemr'
,
'Key'
=>
"/123/source"
,
])
->
shouldBeCalled
()
->
willReturn
(
$cmd
);
$s3
->
createPresignedRequest
(
Argument
::
any
(),
Argument
::
any
())
->
willReturn
(
$request
);
$request
->
getUri
()
->
willReturn
(
'aws-signed-url'
);
$this
->
setKey
(
123
);
$this
->
getPresignedUrl
()
->
shouldReturn
(
'aws-signed-url'
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment