CDN Manager API

Powerful file storage and delivery API with resumable uploads

API Base URL

https://cdn-625414.cmapps.eu

Use this URL as the base for all API requests.

Complete Usage Flow

  1. Get API Key: Contact your administrator to obtain an API key for your application
  2. Upload File: Use TUS protocol to upload files with your API key in X-API-Key header
  3. Get File ID: After upload completes, extract the file ID from the TUS upload URL
  4. Generate Signed URL: Make POST request to /v1/signed-url with the file ID
  5. Access File: Use the signed URL to display/stream/download the file
Example workflow:
Upload → Get fileId → Generate signed URL → Use URL in <img>, <video>, or download link

Authentication

All API requests require authentication using an API key. Include your API key in the request header:

X-API-Key: your_api_key_here
Important: Keep your API key secure. Never commit it to version control or expose it in client-side code.

Step 1: Get Your API Key

How to obtain an API key:

Contact your system administrator to request an API key for your application. Each API key is unique and provides access to your own isolated storage space.

API Key Format:

Security Notice: Never expose your API key in client-side code or public repositories. Use environment variables or secure backend storage.

Step 2: Upload File (TUS Resumable Upload)

TUS protocol enables resumable file uploads. Perfect for large files and unstable connections.

POST https://cdn-625414.cmapps.eu/tus/

Using tus-js-client (JavaScript)

import * as tus from 'tus-js-client';

const file = document.getElementById('file-input').files[0];

const upload = new tus.Upload(file, {
  endpoint: 'https://cdn-625414.cmapps.eu/tus/',
  headers: {
    'X-API-Key': 'cdn_xxxxxxxxxxxxxxxxxxxxxx'  // Your API key from admin panel
  },
  metadata: {
    filename: file.name,
    filetype: file.type,
    originalName: file.name
  },
  chunkSize: 5 * 1024 * 1024, // 5MB chunks
  retryDelays: [0, 1000, 3000, 5000],
  onError: (error) => {
    console.error('Upload failed:', error);
  },
  onProgress: (bytesUploaded, bytesTotal) => {
    const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2);
    console.log(`Progress: ${percentage}%`);
  },
  onSuccess: () => {
    console.log('Upload completed!');
    console.log('File ID:', upload.url.split('/').pop());
  }
});

upload.start();

Using Python (tus-py-client)

from tusclient import client

my_client = client.TusClient('https://cdn-625414.cmapps.eu/tus/')

uploader = my_client.uploader(
    'path/to/file.mp4',
    headers={'X-API-Key': 'cdn_xxxxxxxxxxxxxxxxxxxxxx'},
    metadata={
        'filename': 'file.mp4',
        'filetype': 'video/mp4'
    },
    chunk_size=5242880  # 5MB
)

uploader.upload()
print(f"File ID: {uploader.url.split('/')[-1]}")
Benefits of TUS:
  • Resume interrupted uploads automatically
  • Upload large files (up to 2GB) reliably
  • Better bandwidth utilization with chunked uploads
  • Cross-platform support with official clients

Step 3: List Your Files (Optional)

GET https://cdn-625414.cmapps.eu/v1/files

Query Parameters

page integer optional
Page number (default: 1)
page_size integer optional
Items per page (default: 50, max: 100)
type string optional
Filter by file type (image, video, audio, document, other)
from date optional
Filter files created after this date (ISO 8601 format)
to date optional
Filter files created before this date (ISO 8601 format)

Example Request

curl -X GET "https://cdn-625414.cmapps.eu/v1/files?page=1&page_size=20&type=image" \
  -H "X-API-Key: cdn_xxxxxxxxxxxxxxxxxxxxxx"

Example Response

{
  "files": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "type": "image",
      "originalName": "photo.jpg",
      "ext": ".jpg",
      "mime": "image/jpeg",
      "sizeBytes": "2048576",
      "sha256": "abc123...",
      "storagePath": "tenant_xyz/2024/01/15/abc123.jpg",
      "createdAt": "2024-01-15T10:30:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "pageSize": 20,
    "total": 45,
    "totalPages": 3
  }
}

Step 4: Generate Signed URL

Create temporary signed URLs for secure file access. This is required to access your uploaded files.

POST https://cdn-625414.cmapps.eu/v1/signed-url

Request Body

fileId string (uuid) required (or storagePath)
File UUID to generate signed URL for
storagePath string required (or fileId)
Storage path of the file
expSeconds integer optional
URL expiration in seconds (default: 3600, min: 60, max: 86400)

Example Request

curl -X POST "https://cdn-625414.cmapps.eu/v1/signed-url" \
  -H "X-API-Key: cdn_xxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "fileId": "550e8400-e29b-41d4-a716-446655440000",
    "expSeconds": 7200
  }'

Example Response

{
  "url": "/cdn/550e8400-e29b-41d4-a716-446655440000.jpg?exp=1706180400&sig=abc123...",
  "path": "/cdn/550e8400-e29b-41d4-a716-446655440000.jpg",
  "exp": 1706180400,
  "sig": "abc123def456...",
  "expiresAt": "2024-01-25T12:00:00.000Z"
}
Important: Add the base URL to use the signed URL:
https://cdn-625414.cmapps.eu/cdn/550e8400-e29b-41d4-a716-446655440000.jpg?exp=1706180400&sig=abc123...

Step 5: Use the File URL

GET https://cdn-625414.cmapps.eu/cdn/:fileId

Use the signed URL to access your files. Supports range requests and video streaming.

Query Parameters

exp integer required
Unix timestamp when the URL expires
sig string required
HMAC signature for URL verification

Example Usage

<!-- Direct image display -->
<img src="https://cdn-625414.cmapps.eu/cdn/file-id.jpg?exp=123456&sig=abc123" />

<!-- Video streaming with player -->
<video controls>
  <source src="https://cdn-625414.cmapps.eu/cdn/file-id.mp4?exp=123456&sig=abc123" type="video/mp4">
</video>

<!-- Direct download -->
<a href="https://cdn-625414.cmapps.eu/cdn/file-id.pdf?exp=123456&sig=abc123" download>
  Download PDF
</a>
Features:
  • Automatic MIME type detection
  • Range request support for video streaming
  • Efficient caching headers
  • Signature validation for security

Rate Limits

API requests are rate-limited to ensure fair usage:

Error Responses

The API uses standard HTTP status codes and returns errors in JSON format:

{
  "error": "File not found"
}

Common Status Codes

Complete Working Example

Copy and paste this complete example to upload a file and get its URL:

// 1. Upload file using TUS
import * as tus from 'tus-js-client';

const API_KEY = 'cdn_xxxxxxxxxxxxxxxxxxxxxx'; // Replace with your API key
const API_BASE = 'https://cdn-625414.cmapps.eu';

const uploadFile = async (file) => {
  return new Promise((resolve, reject) => {
    const upload = new tus.Upload(file, {
      endpoint: `${API_BASE}/tus/`,
      headers: {
        'X-API-Key': API_KEY
      },
      metadata: {
        filename: file.name,
        filetype: file.type
      },
      onError: reject,
      onSuccess: () => {
        const fileId = upload.url.split('/').pop();
        resolve(fileId);
      }
    });
    upload.start();
  });
};

// 2. Generate signed URL for the uploaded file
const getSignedUrl = async (fileId) => {
  const response = await fetch(`${API_BASE}/v1/signed-url`, {
    method: 'POST',
    headers: {
      'X-API-Key': API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      fileId: fileId,
      expSeconds: 3600
    })
  });
  return response.json();
};

// 3. Complete usage
const file = document.getElementById('file-input').files[0];
const fileId = await uploadFile(file);
console.log('Uploaded file ID:', fileId);

const signedUrl = await getSignedUrl(fileId);
const fullUrl = `${API_BASE}${signedUrl.url}`;
console.log('Full file URL:', fullUrl);

// Now use fullUrl in your <img>, <video>, or download link
Steps:
  1. Replace API_KEY with your actual API key
  2. Select a file with document.getElementById('file-input')
  3. Run the code - it will upload and return the full URL
  4. Use the returned URL to display/stream/download the file

Need Help?

For additional support or questions, please contact your administrator.