This project implements a RESTful API for managing and streaming music files using Java and Spring Boot. It provides endpoints for uploading, retrieving, streaming, downloading, and deleting audio files.
- File Upload: Upload music files directly to the server storage.
- Data Persistence: Stores file metadata (including file paths) in a database.
- Audio Streaming: Supports HTTP Range requests for efficient audio streaming playback.
- File Retrieval: Download files or retrieve them for inline playback.
- Management: List all available tracks or delete specific files.
The following sections detail the available endpoints. Postman screenshots are included to demonstrate functionality.
Endpoint: POST /api/songs/upload
Description: Uploads a music file (multipart/form-data) to the server. The file is stored locally, and its metadata is saved to the database.
Endpoint: GET /api/songs
Description: Retrieves a list of all music files stored in the database.
Endpoint: GET /api/songs/{id}
Description: Retrieves a specific song file by its unique ID. Returns the file resource for inline use.
Endpoint: GET /api/songs/{id}/stream
Description: Streams audio content for the specified song ID. This endpoint supports the Range header, allowing clients to request specific byte ranges for seeking and partial content delivery (HTTP 206).
Endpoint: GET /api/songs/{id}/download
Description: Initiates a file download for the specified song ID.
Endpoint: DELETE /api/songs/{id}
Description: Removes the song record from the database. Note that this operation currently removes the database entry.
This project includes tests to verify core functionality:
- Upload: Tests the
POST /api/songs/uploadendpoint. - Download: Tests the
GET /api/songs/{id}/downloadendpoint. - Get All Songs: Tests retrieval of the song list via
GET /api/songs. - Get Song By ID: Tests
GET /api/songs/{id}for both existing and non-existing IDs (validating 404 response).
You can run these tests using your IDE or Maven.
- Java: Core programming language.
- Spring Boot: Framework for building the REST API application.
- Spring Web: For building web, including RESTful, applications using Spring MVC.
- Spring Data JPA: For interaction with the database.
The following resources were used in the development of this project and are recommended for further reading:
- Building an Application with Spring Boot
- Building a RESTful Web Service
- Uploading Files
- HTTP Range Requests (MDN)
For instructions on how to publish this project to GitHub Packages, see PUBLISHING.md.





