- File Upload: Users submit an image via the registration form.
- Transmission: The uploaded file is sent from the frontend to the server.
- File Handling: Multer on the server receives and processes the uploaded file.
- Image Processing: Sharp is used to resize the image as needed.
- Storage Process: The processed image and a secure key (generated through crypto) are sent to an S3 bucket.
- URL Retrieval: The resulting URL of the uploaded image is obtained from S3.
- Key Storage: Only the secret key is saved in the database.
- Key Transmission: The profile key is immediately sent back to the user.
- Display Image: Using the received profile key, the frontend requests and displays the user's image from the S3 bucket.
- User Data Validation: Upon correct email, password, and username, the image key is associated with the user data and stored in the database.
- Error Management: If a registration error occurs, the image from S3 is promptly deleted, along with its associated key in the database. The frontend image upload state is cleared.
- Retry Process: Users must re-upload the image along with accurate data.
- Image Re-upload: Upon re-upload, the image is saved to S3 again, and its corresponding key is retrieved. The image URL is fetched using this key.
- Validation Loop: This process continues until correct data and image are provided.
- Successful Registration: If the user provides accurate data and image, the image remains in the S3 bucket. The image key and user data are saved to the database and also call the delete function to delete the all previous keys from the s3 database.
This process ensures that user images are securely stored and associated with their data while allowing for efficient error handling and retries during registration.
