This is a Spring Boot service that allows capturing photos from a web camera and automatically uploading them to Google Drive with user-based organization. The application features advanced camera conflict detection, modern responsive UI, and intelligent photo management.
- Web camera photo capture: Modern and responsive interface with enhanced button layout
- Automatic user organization: Each user has their own folder in Google Drive
- Name personalization: Files include the user's name and are organized by user
- Photo gallery: View and manage the latest photos taken
- Motion detection: Prevents blurry photos with intelligent stabilization
- Photo download: Download photos locally with automatic cloud backup
- Camera conflict detection: Smart handling of camera usage conflicts
- Multi-device support: Responsive design for mobile, tablet, and desktop
- Enhanced error handling: Comprehensive camera access error management
- Auto-upload on download: Photos are automatically backed up when downloaded
- π€ User Button: Far left - Change user name and manage settings
- π· Take Photo: Center - Large, prominent capture button
- π Camera Toggle: Far right - Switch between front and rear cameras
- Desktop: Full-size buttons with optimal spacing and gradients
- Mobile: Touch-friendly sizes with proper spacing
- Landscape: Optimized layout for horizontal orientation
- Adaptive: Buttons stack vertically on very small screens
- Gradient backgrounds and modern shadows
- Enhanced hover effects and button animations
- Improved tooltips with better positioning
- Professional typography and spacing
The system automatically organizes photos with intelligent naming and folder structure:
Google Drive/
βββ Juan-fotos/
β βββ Juan-camera-photo-2025-07-07_14-30-45.jpg
β βββ Juan-camera-photo-2025-07-07_14-35-22.jpg
β βββ Juan-camera-photo-2025-07-07_14-40-15.jpg
βββ Maria-fotos/
β βββ Maria-camera-photo-2025-07-07_15-10-30.jpg
β βββ Maria-camera-photo-2025-07-07_15-15-45.jpg
βββ Pedro-fotos/
βββ Pedro-camera-photo-2025-07-07_16-00-12.jpg
- Format:
{UserName}-camera-photo-{YYYY-MM-DD}_{HH-MM-SS}.jpg - High-quality JPEG with 95% quality setting
- Automatic timestamp inclusion for easy sorting
- Welcome prompt requests user's name on app launch
- Name validation ensures file system compatibility (2-30 characters, no special characters)
- Automatic folder creation:
{UserName}-fotosin Google Drive - Local storage persistence for seamless future sessions
- Name change: π€ button to update name at any time
- Session persistence: Name maintained between browser sessions
- Input validation: Safe names that work across all file systems
- Visual feedback: Clear messages about folder locations and upload status
- Automatic folder creation and organization
- User-specific photo separation
- Fallback to main folder if user folder creation fails
- Sanitized folder names for cross-platform compatibility
- Multiple camera support: Automatic detection of front and rear cameras
- Tap-to-focus: Touch anywhere on the video to focus the camera
- Motion detection: Intelligent blur prevention with real-time feedback
- Anti-blur settings: Automatic application of optimal camera settings
- Image stabilization: Hardware stabilization when available
- Pre-flight checks: Tests camera availability before starting
- Conflict resolution: Detects when camera is in use by other tabs/applications
- User guidance: Step-by-step instructions for resolving camera conflicts
- Automatic recovery: Reconnection options when camera becomes available
- Browser-specific help: Tailored permission instructions for each browser
- Comprehensive error messages: Specific guidance for each error type
- Permission management: Instructions for enabling camera access
- Retry mechanisms: Smart retry with user feedback
- Fallback options: Page reload and permission reset options
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Drive API:
- Go to "APIs & Services" > "Library"
- Search for "Google Drive API"
- Click "Enable"
- Go to "APIs & Services" > "Credentials"
- Click "Create credentials" > "Service account"
- Provide a name and description for the service account
- Assign the "Editor" or "Owner" role (or a custom role with Drive permissions)
- Click "Create"
- On the credentials page, find your service account
- Click the pencil icon to edit it
- Go to the "Keys" tab
- Click "Add key" > "Create new key"
- Select "JSON" and download the file
- Save the file as
service-account-key.jsoninsrc/main/resources/
If you want photos to be uploaded to a specific folder:
- Create a folder in your Google Drive
- Right-click the folder and select "Share"
- Share the folder with the service account email (found in the JSON file)
- Copy the folder ID from the URL (the part after
/folders/) - Add the ID to
application.properties:google.drive.folder.id=YOUR_FOLDER_ID_HERE
# Google Drive Configuration
google.drive.credentials.path=src/main/resources/service-account-key.json
google.drive.folder.id=
# User Impersonation Configuration (Optional)
google.drive.impersonation.enabled=false
google.drive.impersonation.domain=your-domain.com
google.drive.impersonation.default-user=default@your-domain.com
# Logging Configuration
logging.level.web=DEBUGThe service supports user impersonation for Google Workspace domains, allowing photos to be uploaded directly to specific users' Google Drive accounts instead of a shared service account.
- Google Workspace (G Suite) domain
- Domain administrator access
- Domain-wide delegation configuration
- Enable domain-wide delegation for your service account in Google Cloud Console
- Authorize the service account in Google Workspace Admin Console with scope:
https://www.googleapis.com/auth/drive.file - Update configuration:
google.drive.impersonation.enabled=true google.drive.impersonation.domain=your-company.com google.drive.impersonation.default-user=admin@your-company.com
# Upload to specific user's Google Drive
curl -X POST "http://localhost:8080/api/upload-photo" \
-F "file=@photo.jpg" \
-F "userName=John" \
-F "userEmail=john.doe@your-company.com"Photos are uploaded to the target user's personal Google Drive:
John's Google Drive/
βββ John-fotos/
β βββ John-camera-photo-2025-07-11_14-30-45.jpg
β βββ John-camera-photo-2025-07-11_14-35-22.jpg
See USER_IMPERSONATION_SETUP.md for complete configuration instructions, troubleshooting, and security considerations.
The project includes the following main dependencies:
<!-- Spring Boot Dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- Google Drive API -->
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v3-rev20230822-2.0.0</version>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>1.19.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.43.3</version>
</dependency>
<!-- Reactive Programming -->
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>- PhotoUploadController: RESTful API for photo upload with user support
- GoogleDriveService: Complete Google Drive API integration
- Automatic user folder creation and management
- File upload with personalized naming conventions
- Comprehensive error handling and fallback mechanisms
- Folder permission management and sharing
- Reactive configuration: Asynchronous operations using Project Reactor
- Security: Input validation and sanitization for user data
- Camera management: Advanced WebRTC API implementation
- Multiple camera support with automatic detection
- Real-time motion detection and blur prevention
- Tap-to-focus functionality with coordinate mapping
- Camera conflict detection and resolution
- User interface: Modern responsive design
- CSS Grid and Flexbox for adaptive layouts
- Touch-optimized controls for mobile devices
- Progressive enhancement for different screen sizes
- Photo management: Intelligent gallery system
- Local storage with automatic optimization
- Thumbnail generation and caching
- Batch operations and smart cleanup
- Error handling: Comprehensive user guidance
- Browser-specific permission instructions
- Camera conflict resolution workflows
- Automatic retry mechanisms with exponential backoff
- Initialization:
- User name prompt β Validation β Local storage persistence
- Camera availability check β Conflict detection β Permission verification
- Capture Process:
- Motion detection β Stability verification β Photo capture β Quality optimization
- Upload Workflow:
- FormData preparation β User folder verification β Google Drive upload β Confirmation
- Organization:
- Folder search/creation β Upload with personalized naming β Success notification
- Download Process:
- Local download trigger β Automatic cloud backup β Dual confirmation
- Automatic backup: Downloads trigger silent cloud uploads
- Storage optimization: Dynamic gallery size based on available space
- Session management: Persistent user preferences and photo history
- Performance monitoring: Camera health checks and automatic recovery
- Java 11 or higher
- Maven 3.6 or higher
- Modern web browser with WebRTC support (Chrome, Firefox, Safari, Edge)
- Google Cloud account with Google Drive API access
- HTTPS environment (required for camera access in production)
-
Clone the repository:
git clone <repository-url> cd camera-to-gdrive-service
-
Configure Google Drive (follow the detailed configuration section below)
-
Install dependencies:
mvn clean install
-
Run the application:
mvn spring-boot:run
-
Open in browser:
http://localhost:8080
- User setup: Enter your name when prompted (2-30 characters, no special characters)
- Camera permissions: Allow camera access when the browser requests it
- Camera selection: Use the π button to switch between front/rear cameras
- Take photos: Use the large center button to capture photos
- Automatic organization: Photos are saved to your personal Google Drive folder
- β Smooth camera initialization with conflict detection
- β Real-time motion detection and blur prevention
- β Automatic photo upload to user-specific folders
- β Local gallery with last 6 photos for quick access
- β Download with automatic cloud backup
-
Install dependencies:
mvn clean install
-
Run the application:
mvn spring-boot:run
-
Open your browser and go to
http://localhost:8080
- POST
/api/upload-photo - Parameters:
file(MultipartFile) - Required image fileuserName(String) - User name for folder organization (optional)userEmail(String) - Target user's email for impersonation (optional)
- Response: JSON with uploaded file ID and user information
- Example response:
{ "message": "Photo uploaded successfully to Google Drive", "fileId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "uploadedFor": "Juan", "uploadedToAccount": "juan.doe@company.com" }
- GET
/api/drive-status - Response: JSON with configuration status
- Example response:
{ "configured": true, "folderId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "service": "Google Drive" }
- GET
/api/impersonation-status - Response: JSON with impersonation configuration
- Example response:
{ "impersonationEnabled": true, "domain": "company.com", "defaultUser": "admin@company.com", "configured": true }
- π€ User Button (Left): 65x65px circular button for user management
- π· Take Photo (Center): 240x65px prominent capture button with uppercase text
- π Camera Toggle (Right): 65x65px circular button with camera switch icon
- Modern styling: Gradient backgrounds, enhanced shadows, and smooth animations
- Touch-friendly: Optimized sizes for both mouse and touch interaction
- Motion detection warnings: Real-time feedback to prevent blurry photos
- Tap-to-focus: Touch/click anywhere on the video to focus
- Camera switching: Seamless toggle between front and rear cameras
- Visual stabilization indicators: Color-coded feedback for camera stability
- Integrated gallery: View last 6 photos with thumbnail previews
- Photo actions: Upload, download, or share individual photos
- Dual backup system: Photos automatically backed up when downloaded
- Local storage: Persistent gallery with smart storage management
- Desktop (>768px): Full-size buttons with optimal spacing
- Tablet (β€768px): Moderately sized buttons maintaining usability
- Mobile (β€480px): Compact but touch-friendly button sizes
- Tiny screens (β€320px): Vertical button stacking for maximum usability
- Landscape mode: Optimized layouts for horizontal orientation
- Loading indicators: Clear feedback during photo processing
- Error recovery: Helpful guidance for resolving camera issues
- Tooltips: Contextual help for button functions
- Confirmation messages: Success/error feedback with actionable information
- Service account credentials must be kept secure
- Do not upload the
service-account-key.jsonfile to public repositories - Consider using environment variables for production configuration
- Cause: Another tab, window, or application is using the camera
- Solutions:
- Close other browser tabs that might be using the camera
- Close video conferencing apps (Zoom, Teams, Skype, etc.)
- Close other camera applications
- Restart the browser if the issue persists
- Check Windows/Mac privacy settings for camera access
- Cause: Browser permissions not granted
- Solutions:
- Click the camera icon in the address bar and select "Allow"
- Check browser settings: Privacy & Security β Camera
- Ensure the site is not in the blocked list
- Try incognito/private mode to test permissions
- Clear browser cache and cookies for the site
- Cause: No camera devices detected
- Solutions:
- Check physical camera connections
- Verify camera drivers are installed and updated
- Test camera in other applications
- Restart the computer if needed
- Check Windows Device Manager or Mac System Preferences
- Verify Google Drive configuration:
- Ensure
service-account-key.jsonexists insrc/main/resources/ - Check that Google Drive API is enabled in Google Cloud Console
- Verify service account has proper permissions
- Ensure
- Check folder permissions:
- If using a specific folder, ensure it's shared with the service account
- Verify the folder ID in
application.propertiesis correct
- Network issues:
- Check internet connectivity
- Verify firewall settings allow HTTPS requests
- Test with a smaller image file
- Default location: Photos upload to "My Drive" if no folder is specified
- Folder access: If using a specific folder, verify sharing with service account email
- Permission delays: Google Drive sometimes takes a few minutes to show new files
- Check trash: Files might be in Google Drive trash if there were permission issues
- Automatic handling: App automatically falls back to main folder if user folder creation fails
- Permission verification: Ensure service account can create folders in Google Drive
- Name validation: User names are automatically sanitized for file system compatibility
- Manual verification: Check Google Drive to confirm folder existence
- Character restrictions: Only alphanumeric characters and spaces allowed
- Length limits: 2-30 characters required
- Special characters: Automatically removed or replaced
- Reset option: Use the π€ button to change/reset user name
- Enable camera permissions: Settings β Privacy and security β Site settings β Camera
- Check for browser updates
- Try disabling extensions that might interfere with camera access
- Enable camera permissions: about:preferences#privacy β Permissions β Camera
- Check if WebRTC is enabled: about:config β media.navigator.enabled = true
- Enable camera permissions: Safari β Preferences β Websites β Camera
- Ensure "Auto-Play" is set to "Allow All Auto-Play"
- Hardware acceleration: Enable in browser settings
- Background apps: Close unnecessary applications
- Browser cache: Clear cache and restart browser
- Network: Ensure stable internet connection for initial setup
- Lighting: Ensure adequate, stable lighting
- Stability: Use a tripod or stable surface
- Settings: Motion detection automatically adjusts sensitivity
- File location: Ensure
service-account-key.jsonis in correct directory - File format: Verify JSON file is valid and complete
- Permissions: Check file permissions and accessibility
- Regeneration: Try generating a new service account key
- Java version: Verify Java 11+ is installed
- Maven: Ensure Maven 3.6+ is available
- Port conflicts: Check if port 8080 is already in use
- Dependencies: Run
mvn clean installto refresh dependencies
- Local development: HTTP is acceptable for localhost
- Production: HTTPS is required for camera access
- Certificates: Ensure valid SSL certificates are configured
export GOOGLE_DRIVE_CREDENTIALS_PATH=/path/to/credentials.json
export GOOGLE_DRIVE_FOLDER_ID=your_folder_id
export GOOGLE_DRIVE_ENABLED=true# For detailed debugging
logging.level.com.magumboi.webcameraapp=DEBUG
logging.level.com.google.api=INFO
# For production
logging.level.root=WARN
logging.level.com.magumboi.webcameraapp=INFO- Chrome 90+: Full feature support with hardware acceleration
- Firefox 88+: Complete compatibility with WebRTC features
- Safari 14+: Full support on macOS with camera switching
- Edge 90+: Complete Chromium-based compatibility
- Chrome Mobile: Full camera support with touch controls
- Safari Mobile: Complete iOS integration with front/rear camera switching
- Firefox Mobile: WebRTC support with responsive design
- Samsung Internet: Full compatibility on Android devices
- Tablets: Optimized responsive interface for tablet screens
- Smartphones: Touch-friendly controls with proper spacing
- Desktop webcams: Multiple camera detection and switching
- Laptop cameras: Built-in camera support with tap-to-focus
- Portrait: Vertical layout optimized for mobile phones
- Landscape: Horizontal layout for tablets and desktop
- Auto-rotation: Automatic layout adjustment on device rotation
- Fixed orientation: Button layout adapts to screen constraints
- Touch gestures: Tap-to-focus anywhere on the video
- Button interaction: Large, touch-friendly buttons
- Keyboard navigation: Full accessibility support
- Mouse interaction: Hover effects and click feedback
- Local storage: Photos stored temporarily with automatic cleanup
- Cloud security: Direct upload to Google Drive with service account authentication
- User privacy: No photo data stored on server, direct client-to-cloud upload
- Encryption: All data transmission over HTTPS
- Service account: Secure, limited-scope Google Drive access
- No user login: No personal Google account access required
- Scoped permissions: Minimal required permissions for Google Drive operations
- Key management: Secure storage of service account credentials
- Credential security: Never commit service account keys to version control
- Environment variables: Use environment variables for production credentials
- User input validation: All user names sanitized and validated
- HTTPS enforcement: Required for camera access in production
- Rate limiting: Consider implementing rate limiting for production use
- User name only: Only user name is collected, no other personal data
- Local processing: All image processing happens in the browser
- Automatic cleanup: Local storage automatically managed and cleaned
- No tracking: No analytics or tracking implemented by default
This project is under the license specified in the LICENSE file.