A secure file sharing application that allows users to upload files and generate shareable URLs. Built with Spring Boot and PostgreSQL, featuring JWT authentication and comprehensive file management capabilities.
- User Authentication: Secure registration and login system
- File Upload: Upload files and receive shareable download URLs
- File Download: Access files via unique download tokens
- Admin Controls: Administrative file deletion capabilities
- Download Tracking: Comprehensive logging of file downloads
- JWT Security: Token-based authentication for protected routes
- Backend: Spring Boot (Java 20)
- Database: PostgreSQL
- Authentication: JWT (JSON Web Tokens)
- Build Tool: Maven
- Containerization: Docker & Docker Compose
- Java 20 or higher
- Maven
- Docker and Docker Compose
- PostgreSQL (via Docker)
git clone https://github.com/SelimArslan1/file-shareCreate a .env file in the project root directory and configure the following variables:
POSTGRES_DB=your_database_name
POSTGRES_USER=your_postgres_user
POSTGRES_PASSWORD=your_postgres_password
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/your_database_name
SPRING_DATASOURCE_USERNAME=your_postgres_user
SPRING_DATASOURCE_PASSWORD=your_postgres_passwordmvn clean package -DskipTests
# Start the application with Docker Compose
docker-compose up --buildThe application will be available at http://localhost:8080
POST /auth/register
Content-Type: application/json
{
"username": "your_username",
"email": "your_email@example.com",
"password": "your_password",
"repeatedPassword": "your_password"
}
POST /auth/login
Content-Type: application/json
{
"email": "your_email",
"password": "your_password"
}
POST /files/upload
Authorization: Bearer <your_jwt_token>
Content-Type: multipart/form-data
Form Data:
- file: [your file]
Response: Returns a shareable download URL with unique token
GET /files/download/{downloadToken}
Authorization: Bearer <your_jwt_token>
DELETE /admin/delete
Authorization: Bearer <admin_jwt_token>
Content-Type: application/json
{
"downloadToken": "download_token"
}
- Method: POST
- URL:
http://localhost:8080/auth/register - Headers:
Content-Type: application/json - Body (raw JSON):
{
"username": "testuser",
"email": "test@example.com",
"password": "securepassword123",
"repeatedPassword": "securepassword123"
}- Method: POST
- URL:
http://localhost:8080/auth/login - Headers:
Content-Type: application/json - Body (raw JSON):
{
"email": "test@example.com",
"password": "securepassword123"
}- Note: Copy the JWT token from the response for subsequent requests
- Method: POST
- URL:
http://localhost:8080/files/upload - Headers:
Authorization: Bearer <your_jwt_token>
- Body:
- Type:
form-data - Key:
file - Value: Select your file
- Type:
- Method: GET
- URL:
http://localhost:8080/files/download/{downloadToken} - Headers:
Authorization: Bearer <your_jwt_token>
- Method: DELETE
- URL:
http://localhost:8080/admin/delete - Headers:
Authorization: Bearer <admin_jwt_token>Content-Type: application/json
- Body (raw JSON):
{
"downloadToken": "download_token"
}The application uses PostgreSQL with the following main entities:
- Users: User account information and credentials
- Files: File metadata including upload information and download tokens
- Download Logs: Tracking and analytics for file downloads
- JWT Authentication: All protected routes require valid JWT tokens
- Role-based Access: Admin routes restricted to admin users
- Secure File Access: Files accessible only via unique download tokens
- Password Encryption: User passwords are securely hashed
- Download Tracking: All file access is logged for security monitoring