# S3 File Storage

With the S3 Datasource Plugin, you can connect to your Amazon S3 Storage to upload and manage Files.

### Prepare Amazon S3 Buckets

<figure><img src="https://1375341043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzo5R6EJIlCfRyDLbDnBv%2Fuploads%2Fgit-blob-f90252264e188e51724992964fcc2b00ad24c50d%2FAmazon%20S3%20Buckets.png?alt=media" alt=""><figcaption><p>Create at least one Bucket in a Region.</p></figcaption></figure>

Next to Buckets, you need to create a User to configure Access Keys

<figure><img src="https://1375341043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzo5R6EJIlCfRyDLbDnBv%2Fuploads%2Fgit-blob-e67b027af896af5e133e8b94ca1410bfbac86de9%2FAmazon%20S3%20User.png?alt=media" alt=""><figcaption><p>Create a Amazon AWS User, give with a Policy the desired Access for your Buckets</p></figcaption></figure>

Now you can create the Access Keys

<figure><img src="https://1375341043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzo5R6EJIlCfRyDLbDnBv%2Fuploads%2Fgit-blob-b3067be28e1aa811603bd0974238bcf9836f8f9d%2FAmazon%20S3%20Access%20Key.png?alt=media" alt=""><figcaption><p>The Access Keys are needed to connect to your S3 Buckets</p></figcaption></figure>

### Create a Datasource to Connect to your Bucket

To use Amazon S3, you need to connect to your Buckets.

<figure><img src="https://1375341043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzo5R6EJIlCfRyDLbDnBv%2Fuploads%2Fgit-blob-25a376eccd757851b4d82fa3c8acd65b2c9971d9%2FData%20Plugin%20%20S3%20Buckets.png?alt=media" alt=""><figcaption><p>You need to have at least one Bucket as also your Access Key for S3</p></figcaption></figure>

The URL contains the Amazon AWS Region, in which you created the Buckets. This does not affect replica regions.

```
https://s3.<your_aws_region>.amazonaws.com
```

### Upload Files

With the help of the file upload component, you can now gather the data that you want to upload as Fle to your Bucket. There are two possible file types in general.

* Text based Files like JSON or CSV
* Binary Files

{% hint style="info" %}
Binary files are represented in the Browser as base64 encoding. However, after the transport to the S3 Bucket, they will be available as binary files.
{% endhint %}

From the possible actions of the S3 Datasource Plugin you can choose "Upload file" and fill in the settings.

<figure><img src="https://1375341043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzo5R6EJIlCfRyDLbDnBv%2Fuploads%2Fgit-blob-91c2175e57d9c09ad3860944bc3bba411cbcf7e9%2FData%20Plugin%20%20S3%20File%20Upload.png?alt=media" alt=""><figcaption></figcaption></figure>

### List Buckets and Files

Choose "List Buckets" to get a JSON List of your S3 Buckets.

<figure><img src="https://1375341043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzo5R6EJIlCfRyDLbDnBv%2Fuploads%2Fgit-blob-91e8ec16a1e80b5f6b5d26266308044d75982f94%2FData%20Plugin%20%20S3%20Get%20Buckets.png?alt=media" alt=""><figcaption><p>You can get all your S3 Buckets as Data List.</p></figcaption></figure>

```json
// Response of "List buckets"
[
  {
    "name": "lowcoder-documentation-bucket"
  }
]
```

With the name of the Bucket you can now request a list of all Files.

<figure><img src="https://1375341043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzo5R6EJIlCfRyDLbDnBv%2Fuploads%2Fgit-blob-45331f5ea823d3d070fdc5ab95e74af75a44ae73%2FData%20Plugin%20%20S3%20Get%20Files.png?alt=media" alt=""><figcaption><p>Get a List of all Files in your Bucket as JSON</p></figcaption></figure>

```
// Response of "List files"
[
  {
    "name": "open_issues.json",
    "size": 247285,
    "lastModified": "2023-06-24T18:28:51.000Z",
    "signedUrl": "",
    "url": "https://s3.eu-central-1.amazonaws.com/lowcoder-documentation-bucket/open_issues.json"
  },
  {
    "name": "test.json",
    "size": 236646,
    "lastModified": "2023-06-24T18:17:13.000Z",
    "signedUrl": "",
    "url": "https://s3.eu-central-1.amazonaws.com/lowcoder-documentation-bucket/test.json"
  }
]
```

### Read / use Files

Based on Bucket & File name you can now request the Data of Files.

<figure><img src="https://1375341043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzo5R6EJIlCfRyDLbDnBv%2Fuploads%2Fgit-blob-d33434dc21f0edb54f61e94e8911ec1b9356031b%2FData%20Plugin%20%20S3%20Get%20File.png?alt=media" alt=""><figcaption><p>Get the file as JSON / Text or base64 encoded.</p></figcaption></figure>

An alternative way to access the File is via the secure Link (Signed URL). To get the "signed Link URLs" for your files, just use the "List files" method including the "Return signed url" checkbox.

<figure><img src="https://1375341043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzo5R6EJIlCfRyDLbDnBv%2Fuploads%2Fgit-blob-d3898297f201cfe5605a96da24f0c2e29c4da03d%2FData%20Plugin%20%20S3%20Get%20Files%20with%20Signed%20Link.png?alt=media" alt=""><figcaption><p>Get direct accessible Links of your files</p></figcaption></figure>

You can now use the URL of each file and for example, display it in the File viewer or with the [Image Component](https://docs.openflower.org/build-applications/app-editor/visual-components/image).

### Delete Files

You can use the Method "Delete file" to ... delete a single file from your Bucket.

<figure><img src="https://1375341043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzo5R6EJIlCfRyDLbDnBv%2Fuploads%2Fgit-blob-b482af5245e12e8be5f9cf5597bf8c9c7f0b12cb%2FData%20Plugin%20%20S3%20File%20Delete.png?alt=media" alt=""><figcaption><p>You can delete single files from your Bucket</p></figcaption></figure>
