Description
Currently, the artwork GET and POST routes use mock URLs for image storage. This task updates the routes to integrate Cloudinary for storing and serving actual images and videos uploaded by authenticated users and guests.
Acceptance Criteria
-
POST Route (/api/artworks)
- Replace the mock upload function with
cloudinary.uploader.upload.
- Store files under structured folders:
prod/artists/{user_id or 'guest'}.
- Support both images and videos using
resource_type: 'auto'.
- Generate thumbnail URLs using Cloudinary transformations (e.g., width 400px, crop
fill).
- Return
image_url and thumbnail_url in the response.
-
GET Route (/api/artworks)
- No change needed to DB query logic.
- Ensure
image_url and thumbnail_url now point to real Cloudinary-hosted assets.
-
Validation
- Maintain existing validations: file type, file size (max 10MB), title, description, tools_used, and guest info.
- Handle Cloudinary upload errors, returning appropriate HTTP error codes.
-
Testing
- Upload an image as a logged-in user and as a guest.
- Confirm images appear in Cloudinary Media Library under the correct folder.
- Confirm thumbnails are generated correctly.
- Confirm DB stores the correct URLs.
- Confirm GET route serves the real images correctly in the public gallery.
Notes
- Maintain all existing validation logic from the current mock implementation.
- Keep DB schema unchanged; only update URLs stored for each artwork.
Description
Currently, the artwork
GETandPOSTroutes use mock URLs for image storage. This task updates the routes to integrate Cloudinary for storing and serving actual images and videos uploaded by authenticated users and guests.Acceptance Criteria
POST Route (
/api/artworks)cloudinary.uploader.upload.prod/artists/{user_id or 'guest'}.resource_type: 'auto'.fill).image_urlandthumbnail_urlin the response.GET Route (
/api/artworks)image_urlandthumbnail_urlnow point to real Cloudinary-hosted assets.Validation
Testing
Notes