Skip to content

Commit

Permalink
Update README.md (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstaFrode authored Jan 31, 2024
1 parent e26c85d commit 419d1af
Showing 1 changed file with 19 additions and 92 deletions.
111 changes: 19 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ service iptables restart
### Method one
Download the latest release of the binary application directly at:
```
wget https://github.com/CESSProject/DeOSS/releases/download/v0.3.4/DeOSS0.3.4.linux-amd64.tar.gz
wget https://github.com/CESSProject/DeOSS/releases/download/v0.3.5/DeOSS0.3.5.linux-amd64.tar.gz
```

### Method two
Expand Down Expand Up @@ -216,64 +216,18 @@ The public API endpoint URL of DeOSS is the server you deploy, All endpoints des

> If you feel that you do not have enough space, you can expand it by means of [ExpansionSpace](https://github.com/CESSProject/W3F-illustration/blob/4995c1584006823990806b9d30fa7d554630ec14/deoss/expansionSpace.png).
## Authentication

The DeOSS API uses bearer tokens to authenticate requests.

Your tokens carry many privileges, so be sure to keep them secure! Do not share your *secret tokens* in publicly accessible locations such as a GitHub repository, client-side code, and so forth.

The bearer token is a cryptic string, usually generated by the server in response to a auth request. The client must send this token in the `Authorization` header when making requests to protected resources:

| Authorization: token |
| --------------------- |


## Get token

| **POST** /auth |
| --------------- |

The authorization interface is used to generate user tokens.

- Request Header

| key | value |
| ------------ | ---------------- |
| Content-Type | application/json |

- Request Body

| field | value |
| ------- | ----------------------------- |
| account | your account address |
| message | custom Signature Message |
| signature | signature data |

*Reference for signature calculation method: https://github.com/CESSProject/cess-toolset/tree/main/cess-sign*


- Responses

Response schema: `application/json`

| HTTP Code | Message | Description |
| --------- | -------------------------- | ----------------------------- |
| 200 | token | returns a token |
| 400 | Invalid.Body | body content error |
| 400 | InvalidParameter.Account | account error |
| 400 | InvalidParameter.Message | message error |
| 400 | InvalidParameter.Signature | signature error |
| 403 | NoPermission | signature verification failed |
| 500 | InternalError | service internal error |

- Request example

```shell
# curl -X POST URL/auth -d '{"account": "cXgfFb...bjfR", "message": "123456", "signature": [44,30,117,...,109,141]}' -H "Content-Type: application/json"
```
## Public request header

The public request header identifies you, all interfaces require you to provide identity information, the easiest way to do this is to sign with your account in the [block browser](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ftestnet-rpc1.cess.cloud%2Fws%2F#/signing) and then fill in the information into the public request header as follows:

| key | value |
| --------- | ----- |
| Account | cX... |
| Message | ... |
| Signature | 0x... |

:warning:Please add public request header information to all requests.

## Create a bucket

| **PUT** / |
Expand Down Expand Up @@ -304,7 +258,7 @@ Response schema: `application/json`
- Request example

```shell
# curl -X PUT URL/ -H "BucketName: bucketname" -H "Authorization: eyJhbGciOiJIUzI1NiIsI......P0Jrg-hX4bXlIyn5I8ML1g"
# curl -X PUT URL/ -H "BucketName: bucketname" -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..."
```

## Upload a file
Expand All @@ -319,7 +273,6 @@ If the upload is successful, you will get the fid of the file. If you want to en

| key | description |
| ------------- | ------------------ |
| Authorization | token |
| BucketName | stored bucket name |
| cipher | your cipher |

Expand Down Expand Up @@ -355,7 +308,7 @@ Response schema: `application/json`
- Request example

```shell
# curl -X PUT URL/ -F 'file=@test.log;type=application/octet-stream' -H "Authorization: eyJhbGciOiJIUzI...Iyn5I8ML1g" -H "BucketName: bucket1"
# curl -X PUT URL/ -F 'file=@test.log;type=application/octet-stream' -H "BucketName: bucket1" -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..."
```

## Download a file
Expand All @@ -370,7 +323,6 @@ The get file interface downloads the file in the CESS storage system according t
| key | value |
| --------- | -------- |
| Operation | download |
| Account | cX... |

- Responses

Expand All @@ -388,7 +340,7 @@ The response schema for the exception return status is: `application/json`, The
- Request example

```shell
# curl -X GET -o <savefilename> URL/fid -H "Operation: download"
# curl -X GET -o <savefilename> URL/fid -H "Operation: download" -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..."
```

## Delete a file
Expand All @@ -398,12 +350,6 @@ The delete file interface is used for delete a put file.
| **DELETE** /{fid} |
| ------------------ |

- Request Header

| key | value |
| ------------- | ----- |
| Authorization | token |

- Responses

Response schema: `application/json`
Expand All @@ -420,7 +366,7 @@ Response schema: `application/json`
- Request example

```shell
# curl -X DELETE URL/fid -H "Authorization: eyJhbGciOiJIUzI1Ni......g-hX4bXlIyn5I8ML1g"
# curl -X DELETE URL/fid -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..."
```

## Delete multiple files
Expand Down Expand Up @@ -464,7 +410,7 @@ Response schema: `application/json`
- Request example

```shell
# curl -X DELETE URL/ -d '{"files": ["filehash1", "filehash2"]}' -H "Content-Type: application/json" -H "Authorization: eyJhbGciOiJIUzI1Ni......g-hX4bXlIyn5I8ML1g"
# curl -X DELETE URL/ -d '{"files": ["filehash1", "filehash2"]}' -H "Content-Type: application/json" -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..."
```

## Delete a bucket
Expand All @@ -474,12 +420,6 @@ The delete bucket interface is used for delete a bucket, all files in the bucket
| **DELETE** /{BucketName} |
| ------------------------- |

- Request Header

| key | value |
| ------------- | ----- |
| Authorization | token |

- Responses

Response schema: `application/json`
Expand All @@ -496,7 +436,7 @@ Response schema: `application/json`
- Request example

```shell
# curl -X DELETE URL/BucketName -H "Authorization: eyJhbGciOiJIUzI1Ni......g-hX4bXlIyn5I8ML1g"
# curl -X DELETE URL/BucketName -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..."
```

## View bucket info
Expand All @@ -506,12 +446,6 @@ Response schema: `application/json`

This interface is used to view bucket information, including the number of stored files and file IDs.

- Request Header

| key | description |
| ------- | --------------- |
| Account | account address |

- Responses

Response schema: `application/json`
Expand All @@ -528,7 +462,7 @@ Response schema: `application/json`
- Request example

```shell
# curl -X GET URL/BucketName -H "Account: cXgfFbnV9H......PMQLoKbjfR"
# curl -X GET URL/BucketName -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..."
```

## View bucket list
Expand All @@ -538,12 +472,6 @@ Response schema: `application/json`

This interface is used to view all buckets.

- Request Header

| key | description |
| ------- | --------------- |
| Account | account address |

- Responses

Response schema: `application/json`
Expand All @@ -560,7 +488,7 @@ Response schema: `application/json`
- Request example

```shell
# curl -X GET URL/* -H "Account: cXgfFbnV9H......PMQLoKbjfR"
# curl -X GET URL/* -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..."
```

## View file info
Expand All @@ -575,7 +503,6 @@ This interface is used to view the basic information of a file.
| key | value |
| --------- | ----- |
| Operation | view |
| Account | cX... |

- Responses

Expand All @@ -591,7 +518,7 @@ Response schema: `application/json`
- Request example

```shell
# curl -X GET URL/fid -H "Operation: view"
# curl -X GET URL/fid -H "Operation: view" -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..."
```

## License
Expand Down

0 comments on commit 419d1af

Please sign in to comment.