The Storage application is a Spring Boot REST API that allows users to upload, manage, and download files. The application uses MongoDB to store files and metadata. It supports features such as file visibility (PUBLIC/PRIVATE), tagging, and ensures no duplicate files are uploaded.
To build and run the application with Docker, follow these steps:
- Ensure Docker is installed and running on your machine.
- Build the Docker image:
docker-compose build
- Run the application using Docker Compose:
This will start both the MongoDB and the Storage application containers.
docker-compose up
- Endpoint:
POST /api/files - Request Parameters:
file: The file to be uploaded.visibility: Visibility setting (PUBLICorPRIVATE).tags: A list of up to 5 tags.
- Response: A download link for the uploaded file.
- Endpoint:
GET /api/files/{id} - Request Parameters:
id: The ID of the file.
- Response: The file content.
- Endpoint:
DELETE /api/files/{id} - Request Parameters:
id: The ID of the file.userId: The ID of the user (passed as a header).
- Response: No content.
- Endpoint:
GET /api/tags - Response: A list of all available tags.
- Endpoint:
POST /api/tags - Request Parameters:
name: The name of the tag.
- Response: The created tag.
- Endpoint:
DELETE /api/tags/{id} - Request Parameters:
id: The ID of the tag.
- Response: No content.
To test the API endpoints with Postman, you can create the following requests:
-
Upload a File:
- Method:
POST - URL:
http://localhost:8080/api/files - Body:
form-datafile: (Select a file)visibility:PUBLICtags:["tag1", "tag2"]
- Method:
-
Get a File:
- Method:
GET - URL:
http://localhost:8080/api/files/{id}
- Method:
-
Delete a File:
- Method:
DELETE - URL:
http://localhost:8080/api/files/{id} - Headers:
userId:your_user_id
- Method:
-
Get All Tags:
- Method:
GET - URL:
http://localhost:8080/api/tags
- Method:
-
Create a Tag:
- Method:
POST - URL:
http://localhost:8080/api/tags - Body:
rawname:your_tag_name
- Method:
-
Delete a Tag:
- Method:
DELETE - URL:
http://localhost:8080/api/tags/{id}
- Method: