Feature, upload media to S3 as part of micropub request

Squashed commit of the following:

commit 1f1175a4d944f573868dc2282e62fbd1b4e88b6a
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Sun Apr 22 18:46:02 2018 +0100

    Fix file upload tests to reflect that we have now inlined the file upload to S3

commit 40d2af5b76e8f390d0275830390dd89ab4d12f54
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Sun Apr 22 18:45:20 2018 +0100

    Markup the bookmrark test that uses puppeteer, doesn’t play nicely with my old MacBook and let’s me skip that one test

commit bbae1557c87d4d8f3b324abda1a6b8bf66acb8d8
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Sun Apr 22 17:56:25 2018 +0100

    Inline the S3 upload for media

    Smaller images can then be uploaded by the ProcessMedia job. Inline-ing
    the upload prevents an S3 URL being sent that will initially 404.
This commit is contained in:
Jonny Barnes 2018-04-22 18:53:26 +01:00
parent b097dc0f94
commit 8b5b3204c1
4 changed files with 32 additions and 11 deletions

View file

@ -770,7 +770,8 @@ class MicropubControllerTest extends TestCase
public function test_media_endpoint_upload_a_file()
{
Queue::fake();
Storage::fake('local');
Storage::fake('s3');
$file = __DIR__ . '/../aaron.png';
$response = $this->call(
'POST',
@ -778,7 +779,14 @@ class MicropubControllerTest extends TestCase
[],
[],
[
'file' => UploadedFile::fake()->image('scrot.png', 1920, 1080)->size(250),
'file' => new UploadedFile(
$file,
'aaron.png',
'image/png',
filesize(__DIR__ . '/../aaron.png'),
null,
true
),
],
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
);
@ -787,12 +795,14 @@ class MicropubControllerTest extends TestCase
$filename = substr($path, 7);
Queue::assertPushed(ProcessMedia::class);
Storage::disk('local')->assertExists($filename);
// now remove file
unlink(storage_path('app/') . $filename);
}
public function test_media_endpoint_upload_an_audio_file()
{
Queue::fake();
Storage::fake('local');
Storage::fake('s3');
$file = __DIR__ . '/../audio.mp3';
$response = $this->call(
@ -810,12 +820,14 @@ class MicropubControllerTest extends TestCase
$filename = substr($path, 7);
Queue::assertPushed(ProcessMedia::class);
Storage::disk('local')->assertExists($filename);
// now remove file
unlink(storage_path('app/') . $filename);
}
public function test_media_endpoint_upload_a_video_file()
{
Queue::fake();
Storage::fake('local');
Storage::fake('s3');
$file = __DIR__ . '/../video.ogv';
$response = $this->call(
@ -833,12 +845,14 @@ class MicropubControllerTest extends TestCase
$filename = substr($path, 7);
Queue::assertPushed(ProcessMedia::class);
Storage::disk('local')->assertExists($filename);
// now remove file
unlink(storage_path('app/') . $filename);
}
public function test_media_endpoint_upload_a_document_file()
{
Queue::fake();
Storage::fake('local');
Storage::fake('s3');
$response = $this->call(
'POST',
@ -855,6 +869,8 @@ class MicropubControllerTest extends TestCase
$filename = substr($path, 7);
Queue::assertPushed(ProcessMedia::class);
Storage::disk('local')->assertExists($filename);
// now remove file
unlink(storage_path('app/') . $filename);
}
public function test_media_endpoint_upload_an_invalid_file_return_error()

View file

@ -11,6 +11,9 @@ use GuzzleHttp\Handler\MockHandler;
class BookmarksTest extends TestCase
{
/**
* @group puppeteer
*/
public function test_screenshot_of_google()
{
$uuid = (new BookmarkService())->saveScreenshot('https://www.google.co.uk');