Skip to content

Commit

Permalink
Return Etag value from saveToS3 method (#24)
Browse files Browse the repository at this point in the history
* Return Etag from saveToS3 method

* Update Tests
  • Loading branch information
stefanzweifel authored Jul 15, 2022
1 parent e538f16 commit 2ba11a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/BrowsershotLambda.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function throwError(SettledResult $response): void
/**
* @throws CouldNotTakeBrowsershot
*/
public function saveToS3(string $targetPath, string $disk = 's3')
public function saveToS3(string $targetPath, string $disk = 's3'): string
{
$this->setOption('s3', [
'path' => $targetPath,
Expand All @@ -83,5 +83,7 @@ public function saveToS3(string $targetPath, string $disk = 's3')
if (empty($output)) {
throw CouldNotTakeBrowsershot::chromeOutputEmpty("$targetPath on S3 disk: $disk", $output, $command);
}

return $output;
}
}
4 changes: 3 additions & 1 deletion tests/BrowsershotLambdaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
it('stores pdf in s3 bucket', function () {
$this->assertFalse(Storage::disk('s3')->exists('example.pdf'));

BrowsershotLambda::url('https://example.com')->saveToS3('example.pdf');
$etag = BrowsershotLambda::url('https://example.com')->saveToS3('example.pdf');

$this->assertIsString($etag);

$this->assertTrue(Storage::disk('s3')->exists('example.pdf'));
Storage::disk('s3')->delete('example.pdf');
Expand Down

0 comments on commit 2ba11a1

Please sign in to comment.