Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features add bucket controller and signed urls to file:getUrl #26

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4c7f057
feat : Support bucketName in api to override kuzzlerc bucketName config
Jun 20, 2023
49f3855
chore (bucketName) : update docs
Jun 26, 2023
3e3b012
feat: add bucket controller
Jul 3, 2023
e81a0be
chore (bucket create) : add bucketPolicy param for handling custom po…
Jul 4, 2023
0356bb8
chore (bucket create) : add bucketExists check before trying to create
Jul 4, 2023
915e083
chore (fileGetUrl) : support Signed urls
Jul 4, 2023
2c99ba8
chore (bucket create) : add AWS s3 compliant name validation
Jul 4, 2023
538a6f4
Create index.md
GuinierRemi Jul 3, 2023
4478f06
Added docs for bucket creation
GuinierRemi Jul 3, 2023
632f777
Renamed folder to remove space
GuinierRemi Jul 3, 2023
9a12c6c
Added delete documentation
GuinierRemi Jul 3, 2023
9d8185d
chore (s3 plugin) : fixes from manual testing
Jul 4, 2023
c6a2de8
fix ( bucket create ) : duplicate code and properly return name valid…
Jul 4, 2023
f8ba0d9
Added exists documentation
GuinierRemi Jul 4, 2023
bbc37d8
fix (minio) : fix minio incompatibility
Jul 4, 2023
083d0e2
Merge branch 'feat-add-bucket-controller' of https://github.com/kuzzl…
Jul 4, 2023
10e9256
Add singedUrl functionnality in documentation
GuinierRemi Jul 4, 2023
f65f86e
Added optional Policy documentation
GuinierRemi Jul 4, 2023
e524978
Updated docs to add the "disableDotsInName" functionnality
GuinierRemi Jul 4, 2023
5372fb5
chore (s3plugin) : add tests
Jul 10, 2023
e85d932
fix (lint) : correct linting
Jul 10, 2023
fc783e5
Merge branch 'feat-support-bucketName' into feat-add-bucket-controller
Jul 10, 2023
316095b
fix (s3plugin) : remove merge errors, useless returns and conditions
Jul 10, 2023
b15abdc
chore (bucket controller) : add bucket create tests
Jul 10, 2023
8417ba3
chore (s3 plugin) : review fixes and bug fixes
Jul 10, 2023
d6623d7
fixup! chore (s3 plugin) : review fixes and bug fixes
Jul 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/kuzzlerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"bucketName": "your-s3-bucket",
"endpoint": "https://s3.eu-west-3.amazonaws.com",
"s3ClientOptions": {
"s3ForcePathStyle": false
"s3ForcePathStyle": false,
"region" : "eu-west-3"
},
"signedUrlTTL": "20min",
"redisPrefix": "s3Plugin/uploads",
Expand Down
91 changes: 91 additions & 0 deletions doc/2/controllers/bucket/create/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
code: true
type: page
title: create
---

# create

Creates a S3 bucket

## Query Syntax

### HTTP

```http
URL: http://kuzzle:7512/_plugin/s3/bucket/create
Juiced66 marked this conversation as resolved.
Show resolved Hide resolved
Method: POST
Body:
```

```js
{
"bucketName":"<bucketname>",
Juiced66 marked this conversation as resolved.
Show resolved Hide resolved
"bucketRegion":"<bucketregion>",
Juiced66 marked this conversation as resolved.
Show resolved Hide resolved
"bucketOptions":{ <OptionsList> },
"bucketPolicy":{ <PolicyList> },
"bucketCORS":{ <CORS> }
"disableDotsInName":"false"
Juiced66 marked this conversation as resolved.
Show resolved Hide resolved
}
```

### Other protocols

```js
{
"controller": "s3",
"action": "create",

"body": {
"bucketName": "<expression>",
"bucketRegion": "<number_of_result_max>",
"bucketOptions": { <OptionsList> },
"bucketPolicy":{ <PolicyList> },
"bucketCORS":{ <CORS> }
"disableDotsInName":"false"
}
Juiced66 marked this conversation as resolved.
Show resolved Hide resolved
}
```

## Arguments

- `bucketName`: the name of the bucket, bucket will need to follow the [AWS Bucket Name Guidelines](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html).
- `bucketRegion` (optional): the region where you want to create the bucket, see [AWS Documentation](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html) for available regions. Otherwise it will default to the region configured globally.
- `bucketOptions` (optional): Specify options like a custom ACL, otherwise it will default to :

```js
{
ACL: 'public-read'
}
```

- `bucketPolicy` (optional): Specify a custom policy for your bucket.
- `bucketCORS` (optional): Specify a custom CORS policy to add to your bucket, otherwise it will default to :

```js
{
AllowedHeaders: ['*'],
AllowedMethods: ['GET', 'POST', 'PUT'],
AllowedOrigins: ['*'],
}
```

- `disableDotsInName` (optional): changes the name checks on the `bucketName` variable to check for dots, which would prevent [S3 Transfer Acceleration](https://aws.amazon.com/fr/s3/transfer-acceleration/) from working.

## Response

Returns an object with the following properties:

```js
{
"status": 200,
"error": null,
"action": "create",
"controller": "s3/bucket",
"bucketName: "<bucketname>",
"bucketRegion":"<bucketregion>",
"bucketOptions": { <OptionsList> },
"bucketPolicy":{ <PolicyList> },
"bucketCORS": { <CORS> }
Juiced66 marked this conversation as resolved.
Show resolved Hide resolved
}
```
49 changes: 49 additions & 0 deletions doc/2/controllers/bucket/delete/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
code: true
type: page
title: create
---

# delete

Deletes an existing empty S3 bucket

## Query Syntax

### HTTP

```http
URL: http://kuzzle:7512/_plugin/s3/bucket/delete/<bucketName>
Method: DELETE
```

### Other protocols

```js
{
"controller": "s3",
"action": "delete",
"bucketName": "mybucket"

}
```

## Arguments

- `bucketName`: the name of the bucket to delete

Juiced66 marked this conversation as resolved.
Show resolved Hide resolved
## Response

Returns an object with the following properties:

```js
{
"status": 200,
"error": null,
"action": "delete",
"controller": "s3/bucket",
"result": {
"result": "ok"
}
}
```
50 changes: 50 additions & 0 deletions doc/2/controllers/bucket/exists/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
code: true
type: page
title: exists
---

# exists

Check if a S3 bucket exists.

## Query Syntax

### HTTP

```http
URL: http://kuzzle:7512/_plugin/s3/bucket/exists/<bucketName>
Method: GET
```

### Other protocols

```js
{
"controller": "s3",
"action": "exists",
"bucketName": "mybucket",
"bucketRegion": "eu-east-1"
}
```

## Arguments

- `bucketName`: the name of the bucket to delete
- `bucketRegion`: the AWS region where the bucket is located

## Response

Returns an object with the following properties:

```js
{
"status": 200,
"error": null,
"action": "exists",
"controller": "s3/bucket",
"result": {
"result": "true"
}
}
```
5 changes: 5 additions & 0 deletions doc/2/controllers/bucket/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
code: true
type: branch
title: file
---
9 changes: 7 additions & 2 deletions doc/2/controllers/file/get-url/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ Method: GET
{
"controller": "s3/file",
"action": "getUrl",

"bucketName":"<bucketname>",
"bucketRegion":"<bucketregion>",
"signedUrl":"true"
"fileKey": "xen/<uuid>-headcrab.png"
}
```
Expand All @@ -35,7 +37,10 @@ Method: GET
## Arguments

- `fileKey`: [file key](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-keys) in S3 bucket

- `bucketName` (optional): the name of the bucket
- `bucketRegion` (optional): the region where the specified bucket is located,
- `signedUrl` (optional): flag to use a signed url,

---

## Response
Expand Down
Loading