This guide covers the complete content management workflow for administrators: uploading files to Cloudinary, creating content entries, updating content, and managing the content lifecycle.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PhemiT/vaniykeempire-api/llms.txt
Use this file to discover all available pages before exploring further.
Content Upload Flow
Prepare content files
Gather the content file and an optional thumbnail:Supported content types:
- Videos:
.mp4,.mov,.avi(uploaded tocontent/videos) - Audio:
.mp3,.wav,.aac(uploaded tocontent/audio) - PDFs:
.pdf(uploaded tocontent/pdfs)
- Format:
.jpg,.png,.webp - Uploaded to:
content/thumbnails - Recommended size: 1280x720px
- Maximum: 500MB per file
- Configured in:
src/config/cloudinary.js:42-44
Create content with files
Upload files and create content in a single request using Required fields:What happens:
multipart/form-data:title: Content titledescription: Detailed descriptiontype: Content type (video,audio,pdf)category: Category ID (must exist in MongoDB)price: Price in USD (numeric)file: Content file (required)
thumbnail: Thumbnail image filestatus:draftorpublished(default:draft)tags: JSON array of tags
- Files are uploaded to Cloudinary with automatic folder organization
- Cloudinary returns URLs and public IDs
- Content metadata is saved to MongoDB
- File metadata (size, duration) is extracted automatically
Cloudinary Configuration
The API automatically organizes uploads into folders based on content type: Folder structure:- Videos/Audio:
resource_type: 'video' - PDFs:
resource_type: 'image' - Thumbnails:
resource_type: 'image'
Cloudinary configuration is handled automatically. See
src/config/cloudinary.js:12-38 for implementation details.Update Existing Content
Replace content file
Update the content file (old file is automatically deleted from Cloudinary):What happens:
- Old file is deleted from Cloudinary using
filePublicId - New file is uploaded to Cloudinary
- MongoDB record is updated with new URLs and metadata
The
resource_type for deletion is determined automatically based on content type.Content Lifecycle Management
Draft to Published
Content can be created as drafts and published later:draft: Not visible to public, admin-onlypublished: Visible in public listings, available for purchase
View All Content (Admin)
Admins can view all content including drafts:page: Page numberlimit: Items per pagestatus: Filter by status (draft,published)category: Filter by category IDtype: Filter by type (video,audio,pdf)
Delete Content
Permanently delete content and associated files:- Content file is deleted from Cloudinary (using
filePublicId) - Thumbnail is deleted from Cloudinary (if exists)
- MongoDB document is removed
Error Handling
| Status Code | Error | Description |
|---|---|---|
| 400 | Bad request | Missing required fields or invalid file format |
| 401 | Unauthorized | Missing or invalid admin token |
| 403 | Forbidden | User is not an admin |
| 404 | Not found | Content doesn’t exist |
| 413 | Payload too large | File exceeds 500MB limit |
| 500 | Server error | Cloudinary or database error |
Best Practices
Testing File Uploads
Using Postman:- Set method to
POSTorPUT - Set Authorization header with Bearer token
- Select Body → form-data
- Add text fields (title, description, etc.)
- Add file fields (file, thumbnail) and select files
- Send request
Environment Setup
Required environment variables:Cloudinary credentials are available in your Cloudinary dashboard under Account Details.
Source Code References
- Create content:
src/controllers/contentController.js:7 - Update content:
src/controllers/contentController.js:56 - Delete content:
src/controllers/contentController.js:122 - Cloudinary config:
src/config/cloudinary.js:1 - Upload middleware:
src/config/cloudinary.js:40
Next Steps
Content API Reference
Detailed API documentation for content endpoints
Payment Management
View and manage purchases as admin