Overview
Secure Link API is a Java Spring Boot application that creates secure, expiring links with password protection and access limits. This quickstart will guide you through installation, creating your first link, and accessing statistics.Prerequisites
Before you begin, ensure you have the following installed:- Java 21+ - Required for Spring Boot 4.0.2
- Maven - For building and running the application
- MySQL 8.4+ - For production/dev database
- Git - For cloning the repository
Installation
Configure the database
Set up your MySQL database and configure the connection. Create a
.env file or set environment variables:The application uses Flyway for database migrations, so tables will be created automatically on first run.
Start the server
Run the application using Maven with the dev profile:The API will start on
http://localhost:8080Creating Your First Link
URL Shortener
Create a secure link that redirects to an external URL:File Upload
Upload a file and generate a secure download link:Accessing Secure Links
Public Links
Access a link without password protection:Password-Protected Links
For links with password protection, provide the password in theX-Link-Password header:
Response Codes
| Status | Result | Description |
|---|---|---|
| 302 | Redirect | Link is valid, redirecting to target URL |
| 200 | Download | File download initiated |
| 401 | Password Required | Link requires password authentication |
| 404 | Not Found | Link does not exist |
| 410 | Gone | Link expired, revoked, or view limit reached |
Viewing Statistics
Access Summary
Get overall access statistics with efficiency metrics:Link Status
Check the status of all links in the system:Top Accessed Links
View the most frequently accessed links:Hourly Access Distribution
Analyze access patterns by hour:Revoking Links
Manually revoke a link to make it immediately inaccessible:Configuration Options
Environment Variables
| Variable | Description | Default |
|---|---|---|
DB_HOST | MySQL database host | localhost |
DB_PORT | MySQL database port | 3307 |
DB_NAME | Database name | secure_link |
DB_USERNAME | Database username | root |
DB_PASSWORD | Database password | - |
SPRING_PROFILES_ACTIVE | Active Spring profile (dev/prod/test) | dev |
SERVER_PORT | HTTP server port | 8080 |
Application Properties
Key configuration options inapplication.properties:
Next Steps
Core Concepts
Learn about link types, lifecycle, and validation
API Reference
Explore the complete API documentation
Authentication
Learn about API security and authentication
Monitoring
Set up Prometheus metrics and health checks
Deployment
Deploy to production environments
Access Control
Understand expiration, limits, and password protection
Troubleshooting
Database Connection Issues
If you encounter database connection errors:- Verify MySQL is running:
mysql -u root -p - Check credentials in environment variables
- Ensure database exists:
CREATE DATABASE secure_link; - Verify MySQL version is 8.4+
File Upload Failures
If file uploads fail:- Check file size is under 50MB
- Verify storage directory exists and is writable
- Check disk space:
df -h
Authentication Errors
If password-protected links fail:- Ensure password is sent in
X-Link-Passwordheader (not in body or query params) - Verify password matches the one used during link creation
- Check for typos in the header name
Support
- GitHub Repository: WalysonGomes/secure-link-api
- Issues: Report bugs and feature requests on GitHub
- Documentation: Full API reference and guides available in this documentation site
