Cloudinary Integration
Image upload service configuration for product management
Cloudinary Integration
BabyShopHub uses Cloudinary to host product images. This offloads storage costs from Firebase and provides automatic image optimization.
How It Works
When an Admin creates or edits a product, they select images from their device using the image_picker package. Instead of uploading these to Firebase Storage, they are uploaded directly to Cloudinary.
Setup
- Create a Cloudinary account.
- Obtain your Cloud Name, API Key, and Upload Preset.
- Ensure the Upload Preset is set to "Unsigned" to allow uploads directly from the mobile client.
Client-Side Implementation
The CloudinaryService handles the HTTP POST request to the Cloudinary REST API.
Security Considerations
Because we use "Unsigned" uploads from the client, anyone with the upload preset name could technically upload files to your Cloudinary account. To mitigate this:
- Cloudinary allows strict restrictions on allowed file types (e.g., only images).
- Apply transformation limits so massive files are resized immediately.
- Only admins in the app have UI access to trigger this code.