DEV Community

Sagar Kumarsahu
Sagar Kumarsahu

Posted on

Media2URL Developer Platform REST API: High-Performance Presigned Cloudflare R2 Media Ingestion & Zero-Latency CDN Delivery

Media2URL Developer Platform REST API

High-Performance Presigned Cloudflare R2 Media Ingestion & Zero-Latency CDN Delivery

Modern web applications require fast, dependable, and scalable media handling. Media2URL provides an enterprise-grade ingestion and content delivery infrastructure designed specifically for developers, frontend engineers, mobile applications, and AI pipelines.

Whether you are converting uploaded screenshots into instant shareable URLs, ingesting camera capture streams, or routing PDFs and videos through low-latency edge caches, the Media2URL REST API abstracts away the complexity of multipart chunking, presigned storage tokens, and multi-region CDN distribution.


Key Developer Resources & Specifications


Architectural Highlights

Media2URL is engineered to bypass server bottlenecks by coupling instant metadata validation with high-throughput object storage and an edge-accelerated delivery network:

  1. Direct Presigned S3 / Cloudflare R2 Ingestion: Upload massive media payloads directly to edge buckets without saturating intermediate application servers.
  2. Sub-50ms Zero-Latency Edge Routing: Uploaded media is instantly distributed via global Cloudflare CDN Points of Presence (PoPs) with automated Brotli/gzip compression and WebP/AVIF transcoding headers.
  3. Robust CORS & Security: Pre-configured secure cross-origin resource headers allow zero-friction client-side integrations directly from SPAs (React, Next.js, Vue, Svelte) and native iOS/Android clients.
  4. Permanent & Deterministic Asset URLs: Every asset receives an immutable, cache-friendly public URL suitable for production embedding, dynamic markdown rendering, and database persistence.

Specialized Ingestion Endpoints

Media2URL offers 10 purpose-built ingestion routes tailored to specific media formats and workflows:

Media Type Specialized Endpoint & Web Route Supported Formats
Images media2url.com/image-to-link PNG, JPEG, WEBP, SVG, TIFF
Screenshots media2url.com/screenshot-to-url Clipboard pastes, PNG, JPEG
Videos media2url.com/video-to-link MP4, WEBM, MOV, MKV
PDF Documents media2url.com/pdf-to-link PDF
Audio Files media2url.com/audio-to-link MP3, WAV, AAC, OGG, FLAC
Universal Files media2url.com/file-to-link ZIP, TAR, DOCX, XLSX, TXT
Bulk Ingestion media2url.com/bulk-image-upload Multi-asset concurrent batching
HTML Documents media2url.com/html-to-url HTML, HTM
Animated GIFs media2url.com/gif-to-link GIF

Quickstart Integration Examples

1. Direct Presigned Asset Upload (cURL)

Request a presigned ingestion URL from the API gateway:

curl -X POST "https://api.media2url.com/v1/files/upload" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "hero-graphic.png",
    "contentType": "image/png",
    "size": 1048576
  }'
Enter fullscreen mode Exit fullscreen mode

Response:

{
  "success": true,
  "data": {
    "fileId": "file_8f19e4a3b0",
    "uploadUrl": "https://storage.media2url.com/direct-upload/file_8f19e4a3b0?X-Amz-Signature=...",
    "publicUrl": "https://cdn.media2url.com/assets/hero-graphic.png",
    "expiresAt": "2026-10-12T01:30:00Z"
  }
}
Enter fullscreen mode Exit fullscreen mode

Push the binary payload directly to Cloudflare R2:

curl -X PUT "https://storage.media2url.com/direct-upload/file_8f19e4a3b0?X-Amz-Signature=..." \
  -H "Content-Type: image/png" \
  --data-binary "@hero-graphic.png"
Enter fullscreen mode Exit fullscreen mode

2. Node.js / TypeScript SDK Snippet

import axios from 'axios';
import * as fs from 'fs';

interface UploadResponse {
  success: boolean;
  data: {
    fileId: string;
    uploadUrl: string;
    publicUrl: string;
  };
}

async function uploadAsset(filePath: string, mimeType: string): Promise<string> {
  const stats = fs.statSync(filePath);

  // 1. Initiate presigned ingestion
  const initRes = await axios.post<UploadResponse>(
    'https://api.media2url.com/v1/files/upload',
    {
      filename: filePath.split('/').pop(),
      contentType: mimeType,
      size: stats.size,
    },
    {
      headers: {
        Authorization: `Bearer ${process.env.MEDIA2URL_API_KEY}`,
        'Content-Type': 'application/json',
      },
    }
  );

  const { uploadUrl, publicUrl } = initRes.data.data;

  // 2. Stream binary payload directly to edge storage
  const fileStream = fs.createReadStream(filePath);
  await axios.put(uploadUrl, fileStream, {
    headers: {
      'Content-Type': mimeType,
      'Content-Length': stats.size,
    },
  });

  return publicUrl;
}

// Usage:
// const cdnUrl = await uploadAsset('./diagram.png', 'image/png');
// console.log('Asset live at:', cdnUrl);
Enter fullscreen mode Exit fullscreen mode

3. Python 3 Quickstart

import os
import requests

API_KEY = os.getenv("MEDIA2URL_API_KEY")
FILE_PATH = "analytics-report.pdf"

# Step 1: Request presigned ingestion URL
init_response = requests.post(
    "https://api.media2url.com/v1/files/upload",
    headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    },
    json={
        "filename": os.path.basename(FILE_PATH),
        "contentType": "application/pdf",
        "size": os.path.getsize(FILE_PATH)
    }
)
init_data = init_response.json()["data"]

# Step 2: Upload binary directly to Cloudflare R2
with open(FILE_PATH, "rb") as f:
    upload_response = requests.put(
        init_data["uploadUrl"],
        data=f,
        headers={"Content-Type": "application/pdf"}
    )

if upload_response.status_code == 200:
    print(f"Asset publicly accessible at: {init_data['publicUrl']}")
Enter fullscreen mode Exit fullscreen mode

Flexible Pricing & Scaling Tiers

Media2URL caters to individual hobbyists, fast-growing startups, and large-scale enterprise deployments:

Tier Monthly Rate Annual Rate Storage Allocation Monthly Bandwidth Daily Upload Quota
Free $0 $0 250 MB 2 GB 10 uploads/day
Plus $5/mo $48/yr 25 GB 250 GB High throughput
Pro $9/mo $86.40/yr 50 GB 500 GB Priority edge routing
Business $29/mo $278.40/yr 250 GB 3 TB Enterprise CDN & SLA

Compare features and upgrade at https://media2url.com/pricing.


Explore More

Top comments (0)