An open API service indexing awesome lists of open source software.

https://github.com/joeltadeu/dontfile-storage-service


https://github.com/joeltadeu/dontfile-storage-service

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

          

# DontFile Storage

A friend of mine had the brilliant idea to create a service for uploading files saving them in a popular site called dontpad.com as a string. I created a java version just for fun

Here a link for his repository:
[dontpad-storage](https://github.com/publi0/dontpad-storage)

## Architecture
![Alt text](_assets/dontfile-storate-architecture.png?raw=true "DontFile Storage Architecture")

The following flow of the backend to upload and download the files:

![Alt text](_assets/dontfile-storate-api-flow.png?raw=true "DontFile API Flow")

## Endpoints

### Upload File

| EndPoint | Method | Description |
|----------------|:------:|------------------|
| /api/v1/files | POST | Upload new file |

#### Example
````shell
curl --location 'http://localhost:8080/api/v1/files' \
--header 'Content-Type: application/pdf' \
--data '@book.pdf'
````
### Download File

| EndPoint | Method | Description |
|--------------------|:------:|---------------------|
| /api/v1/files/{id} | GET | Download file by id |

#### Example
````shell
curl --location 'http://localhost:8080/api/v1/files/1'
````

### Get Files

| EndPoint | Method | Description |
|---------------|:------:|-------------------|
| /api/v1/files | GET | Get list of files |

#### Example
````shell
curl --location 'http://localhost:8080/api/v1/files'
````

#### Response
````json
[
{
"id": 1,
"uuid": "48677a0d-7de2-4635-bb09-3e30847940ce",
"createdAt": "2024-01-28T20:44:32.400978",
"name": "48677a0d-7de2-4635-bb09-3e30847940ce.pdf",
"url": "https://api.dontpad.com/48677a0d-7de2-4635-bb09-3e30847940ce",
"type": "application/pdf"
}
]
````

## Documentation and Examples

### OpenApi

For the documentation of the APIs, access the link
[http://localhost:8080/swagger-ui.html](http://localhost:8080/swagger-ui.html)

### Postman collection

![Alt text](_assets/postman-collection-folder.png?raw=true "Postman collection folder")

## Build & Run

### Local

```bash
mvn clean install
```
Run the command below to run the application.
```bash
java -jar dontfile-storage-service.jar
```

### Docker

to build
```
docker build -f Dockerfile -t dontfile-storage-service:1.0.0 .
```

to run as a container
```
docker run -d -p 8080:8080 -i -t dontfile-storage-service:1.0.0
```
### Port

8080

## Stack

The following guides illustrate how to use some features concretely:

- Java 17
- H2 database
- Spring-Boot 3.2.2
- Feign Client