All upload endpoints require authentication. See the Authentication Guide for details.
Overview
The file upload system uses:- Google Drive API for storage
- OAuth 2.0 for authentication
- Multipart form data for file uploads
- Public sharing for accessible URLs
Supported File Types
| Upload Type | Accepted Formats | Max Size | Folder |
|---|---|---|---|
| Avatar | JPG, PNG, GIF | 5MB | User Avatars |
| Resume | 10MB | User Resumes | |
| Project Cover | JPG, PNG | 5MB | Projects Cover |
| Skill Icon | SVG, PNG | 1MB | Skills Icon |
| Certificate | PDF, JPG, PNG | 10MB | Certificates |
Google Drive Configuration
The API uses OAuth 2.0 credentials to interact with Google Drive. Configuration is managed inGoogleDriveConfig.java and application.properties.
Environment Variables
Configure these in yourapplication.properties:
Required Environment Variables
| Variable | Description | How to Get |
|---|---|---|
DRIVE_OAUTH_CLIENT_ID | OAuth 2.0 Client ID | Google Cloud Console |
DRIVE_OAUTH_CLIENT_SECRET | OAuth 2.0 Client Secret | Google Cloud Console |
DRIVE_OAUTH_REFRESH_TOKEN | OAuth 2.0 Refresh Token | OAuth Playground |
DRIVE_FOLDER_* | Folder IDs for each file type | Create folders in Google Drive |
Create Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Drive API
Create OAuth 2.0 Credentials
- Navigate to “APIs & Services” > “Credentials”
- Click “Create Credentials” > “OAuth client ID”
- Choose “Web application”
- Add
https://developers.google.com/oauthplaygroundto redirect URIs - Copy the Client ID and Client Secret
Generate Refresh Token
- Go to OAuth 2.0 Playground
- Click settings (gear icon) and check “Use your own OAuth credentials”
- Enter your Client ID and Client Secret
- Select “Drive API v3” >
https://www.googleapis.com/auth/drive.file - Click “Authorize APIs” and follow the flow
- Click “Exchange authorization code for tokens”
- Copy the Refresh Token
Google Drive Service Implementation
TheGoogleDriveServiceImpl.java handles all file operations:
Upload Process
FromGoogleDriveServiceImpl.java:71-100:
Upload Endpoints
All upload endpoints are inUploadController.java and use multipart form data.
Upload Avatar
Upload a profile picture:POST /api/me/upload/avatar
Response:
Upload Resume
Upload a PDF resume/CV:file: PDF file
UploadController.java:42-50:
Upload Project Cover
Upload a cover image for a project:projectId: ID of the project
file: Image file (JPG, PNG)
Upload Skill Icon
Upload an icon for a skill:skillId: ID of the skill
file: Icon file (SVG, PNG preferred)
Upload Certificate File
Upload a certificate document:certificateId: ID of the certificate
file: Certificate file (PDF, JPG, PNG)
Upload Service Implementation
TheUploadService handles file processing and entity updates. Here’s the avatar upload flow:
Error Handling
Common Upload Errors
- File Too Large
- Invalid File Type
- Google Drive Error
- Resource Not Found
Status: Solution: Reduce file size or compress the image/PDF.
413 Payload Too LargeFile Naming Convention
Files are automatically renamed to prevent conflicts:avatar_1_1710432000000.jpgresume_1_1710432123456.pdfproject_cover_5_1710432234567.pngskill_icon_3_1710432345678.svgcertificate_1_1710432456789.pdf
Security Considerations
Spring Boot Upload Configuration
Configure upload limits inapplication.properties:
Best Practices
Optimize Images
Compress images before uploading to reduce storage and improve load times:
- Use JPEG for photos (quality: 80-90)
- Use PNG for graphics with transparency
- Use SVG for icons when possible
- Target sizes: avatars (400x400px), covers (1200x630px)
Use Appropriate Formats
- Avatars: JPG or PNG, square aspect ratio
- Resumes: PDF only, single file
- Project covers: JPG or PNG, 16:9 or 2:1 aspect ratio
- Skill icons: SVG preferred, PNG fallback
- Certificates: PDF preferred for authenticity
Testing Uploads
Test file uploads with Postman or cURL:Next Steps
Managing Portfolio
Learn how to manage profile, experience, education, and projects
Public API
Understand how uploaded files are served to public viewers