Skip to main content

Upload asset

Enterprise

This endpoint is part of Countly Enterprise. To get access, contact sales or compare versions. Existing customers can reach the support portal with questions.

Endpoint​

/i/content/asset-upload

Overview​

Uploads an asset file with compression, thumbnail generation, and GridFS storage.

Authentication​

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions​

  • Required permission: Create on the content feature

Request Parameters​

ParameterTypeRequiredDescription
api_keyStringYes (or auth_token)API key for authentication
auth_tokenStringYes (or api_key)Auth token for authentication
app_idStringYesApplication identifier
assetsFileYesMultipart file upload (max 5 MB)
nameStringNoCustom filename; defaults to uploaded filename
thumbnailStringNoData URL thumbnail (for example data:image/png;base64,...)
tagsStringNoJSON stringified array of tags
widthNumberNoStored as metadata.dimensions.width (only if height is also provided)
heightNumberNoStored as metadata.dimensions.height (only if width is also provided)

Examples​

Example 1: Upload JPEG​

curl -X POST "https://your-server.com/i/content/asset-upload" \
-F "api_key=YOUR_API_KEY" \
-F "app_id=5be987d7b93798516eb5289a" \
-F "assets=@banner.jpg" \
-F "name=campaign_banner_v1" \
-F 'tags=["campaign","banner"]'

Example 2: Upload PNG With Dimensions​

curl -X POST "https://your-server.com/i/content/asset-upload" \
-F "api_key=YOUR_API_KEY" \
-F "app_id=5be987d7b93798516eb5289a" \
-F "assets=@logo.png" \
-F "name=company_logo" \
-F 'tags=["branding","logo"]' \
-F "width=1024" \
-F "height=512"

Response​

Success Response​

{
"status": "Success",
"assetId": "507f1f77bcf86cd799439011"
}

Response Fields​

FieldTypeDescription
statusStringOperation status
assetIdStringGridFS object ID of uploaded asset

Error Responses​

HTTP StatusResponse
400"Missing app_id"
400"File Size exceeds 5MB"
400"Missing file thumbnail"
400"Asset not found"
400"The file named {name} could not be added because it already exists."
400Processing/validation error message from upload flow

Behavior​

  1. Validates request authentication and permissions.
  2. Parses optional metadata (tags, width, height).
  3. Enforces 5 MB max file size.
  4. Compresses image data and generates thumbnail (or uses provided thumbnail).
  5. Saves file and metadata to GridFS.
  6. Returns uploaded assetId.

Limitations​

  • Max file size: 5 MB.
  • Compression handling is implemented for JPEG and PNG inputs.
  • Filenames must be unique within the app-specific GridFS bucket.
  • Auto thumbnail max size is 400 × 400.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly_fs.content_assets{app_id}.filesEndpoint data source** - GridFS file metadata
countly_fs.content_assets{app_id}.chunksEndpoint data source** - GridFS binary chunks