Skip to content

Commit

Permalink
Rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanzweifel committed Mar 29, 2023
1 parent 5e2e3d3 commit fe72ec7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ Alternatively you can publish the `sidecar-browsershot.php` config file and chan

## Reading source from S3

You can store a HTML file on AWS S3 and pass the path to Lambda for it to create the PDF or image from.
You can store an HTML file on AWS S3 and pass the path to Lambda for it to create the PDF or image from.
This is necessary for large source files in order to avoid restrictions on the size of Lambda requests.

```php
use Wnx\SidecarBrowsershot\BrowsershotLambda;

// Use a HTML file from S3 to generate a PDF
BrowsershotLambda::htmlFromS3File('html/example.html')->save('example.pdf');
// Use an HTML file from S3 to generate a PDF
BrowsershotLambda::readHtmlFromS3('html/example.html')->save('example.pdf');

// You can also pass a disk name if required (default: 's3')
BrowsershotLambda::htmlFromS3File('html/example.html', 's3files')->save('example.pdf');
BrowsershotLambda::readHtmlFromS3('html/example.html', 's3files')->save('example.pdf');
```

## Saving directly to S3
Expand Down
9 changes: 2 additions & 7 deletions src/BrowsershotLambda.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,9 @@ public function saveToS3(string $targetPath, string $disk = 's3'): string
}

/**
* Load the html from a file that is stored in S3.
*
* @param string $sourcePath
* @param string $disk
*
* @return static
* Tell BrowsershotLambda to load HTML from a file that is stored in S3.
*/
public static function htmlFromS3File(string $sourcePath, string $disk = 's3'): self
public static function readHtmlFromS3(string $sourcePath, string $disk = 's3'): self
{
return (new static())
->setOption('s3Source', [
Expand Down
2 changes: 1 addition & 1 deletion tests/BrowsershotLambdaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
Storage::disk('s3')->put('example.html', '<h1>Hello world!!</h1>');
$this->assertTrue(Storage::disk('s3')->exists('example.html'));

BrowsershotLambda::htmlFromS3File('example.html')->save('example.pdf');
BrowsershotLambda::readHtmlFromS3('example.html')->save('example.pdf');

$this->assertFileExists('example.pdf');
});

0 comments on commit fe72ec7

Please sign in to comment.