Skip to content

Commit

Permalink
Added docs for SimpleS3 (async-aws#657)
Browse files Browse the repository at this point in the history
* Added docs for SimpleS3

* minor
  • Loading branch information
Nyholm authored May 27, 2020
1 parent e61241c commit 903d5ea
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions couscous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ menu:
sessions:
text: PHP Sessions
url: /integration/sessions.html
simple-s3:
text: Simple S3
url: /integration/simple-s3.html

authentication:
# Authentication providers are in alphabetical order
Expand Down
2 changes: 2 additions & 0 deletions docs/clients/s3.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ The client supports presign of requests to be able to pass the URL to a normal m
person so they can download a file within the next X minutes. Read more about presign
[here](/features/presign.md).

> **Note**: There is a [SimpleS3Client](/integration/simple-s3.md) that might be easier to work with for common use cases.
## Usage

### Upload files
Expand Down
37 changes: 37 additions & 0 deletions docs/integration/simple-s3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
category: integration
---

# Simple S3 client

An abstraction layer above the S3Client that provides simpler functions to common
tasks. The client will automatically switch to multipart upload for large files.

## Install

```shell
composer require async-aws/simple-s3
```

## Usage

```php
use AsyncAws\SimpleS3\SimpleS3Client;

$s3 = new SimpleS3Client();
$resource = \fopen('/path/to/cat/image.jpg', 'r');
$s3->upload('my-image-bucket', 'photos/cat_2.jpg', $resource);
$s3->upload('my-image-bucket', 'photos/cat_2.txt', 'I like this cat');

// Check if a file exists
$s3->has('my-image-bucket', 'photos/cat_2.jpg'); // true

// Get file URL
$url = $s3->getUrl('my-image-bucket', 'photos/cat_2.jpg');
echo $url; // https://my-image-bucket.s3.eu-central-1.amazonaws.com/photos/cat_2.jpg

// Download a file
$resource = $s3->download('my-image-bucket', 'photos/cat_2.jpg')->getContentAsResource();
$text = $s3->download('my-image-bucket', 'photos/cat_2.txt')->getContentAsString();
echo $text; // I like this cat
```
2 changes: 1 addition & 1 deletion src/Integration/Aws/SimpleS3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ composer require async-aws/simple-s3

## Documentation

See https://async-aws.com for documentation.
See https://async-aws.com/integration/simple-s3.html for documentation.

## Contribute

Expand Down

0 comments on commit 903d5ea

Please sign in to comment.