Static files,
served at the edge.

cdn.csndev.com accepts file uploads through a simple API and serves them back over a public URL, cached for a full year at the edge.

Request path — live simulation
CLIENT
EDGE CACHE
ORIGIN
▲ cache HIT — served instantly, origin untouched ▲ cache MISS — first request, routed to origin
Upload a file — integration example

Send a multipart/form-data POST to /upload with your API key. Pick your language below.

<?php

    $apiUrl = 'https://cdn.csndev.com/upload';
    $apiKey = 'YOUR_API_KEY';
    $filePath = '/path/to/photo.jpg';

    $ch = curl_init($apiUrl);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'X-API-Key: ' . $apiKey,
    ]);
    curl_setopt($ch, CURLOPT_POSTFIELDS, [
        'file' => new CURLFile($filePath, mime_content_type($filePath), basename($filePath)),
    ]);

    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    $data = json_decode($response, true);

    if ($httpCode === 200 && $data['success']) {
        echo "Uploaded: " . $data['url'];
    } else {
        echo "Upload failed: " . ($data['error'] ?? 'Unknown error');
    }
async function uploadFile(file) {
      const formData = new FormData();
      formData.append('file', file);

      const res = await fetch('https://cdn.csndev.com/upload', {
        method: 'POST',
        headers: {
          'X-API-Key': 'YOUR_API_KEY',
        },
        body: formData,
      });

      const data = await res.json();

      if (data.success) {
        console.log('Uploaded:', data.url);
        return data.url;
      } else {
        throw new Error(data.error || 'Upload failed');
      }
    }

    // Example: trigger from a <input type="file">
    document.getElementById('fileInput').addEventListener('change', async (e) => {
      const file = e.target.files[0];
      if (!file) return;

      try {
        const url = await uploadFile(file);
        alert('File available at: ' + url);
      } catch (err) {
        alert(err.message);
      }
    });
<?php

    namespace App\Http\Controllers;

    use App\Models\Media;
    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\Http;

    class CdnUploadController extends Controller
    {
        public function upload(Request $request)
        {
            $request->validate([
                'file' => 'required|file|max:2097152', // 2GB (KB e)
            ]);

            $file = $request->file('file');

            $response = Http::withHeaders([
                    'X-API-Key' => config('services.cdn.api_key'),
                ])
                ->attach(
                    'file',
                    fopen($file->getRealPath(), 'r'),
                    $file->getClientOriginalName()
                )
                ->post(config('services.cdn.upload_url'));

            if (! $response->successful() || ! $response->json('success')) {
                return response()->json([
                    'success' => false,
                    'error' => $response->json('error') ?? 'CDN upload failed',
                ], 422);
            }

            $data = $response->json();

            // Storage e kichu save hocche na — sudhu CDN theke asha direct URL DB te jacche
            $media = Media::create([
                'name' => $file->getClientOriginalName(),
                'url' => $data['url'],
                'extension' => $file->getClientOriginalExtension(),
                'size' => $file->getSize(),
            ]);

            return response()->json([
                'success' => true,
                'id' => $media->id,
                'url' => $media->url,
            ]);
        }
    }

    // routes/web.php
    // Route::post('/upload', [CdnUploadController::class, 'upload'])->name('upload');

    // .env
    // CDN_UPLOAD_URL=https://cdn.csndev.com/upload
    // CDN_API_KEY=your-secret-upload-key

    // config/services.php
    // 'cdn' => [
    //     'upload_url' => env('CDN_UPLOAD_URL'),
    //     'api_key' => env('CDN_API_KEY'),
    // ],
Get / share a file

Open the URL returned by the upload response directly — no auth needed for public files.

https://cdn.csndev.com/files/<filename>
What this site does
STORE

Every upload gets a unique filename and is written to disk once.

CACHE

Responses are marked immutable for a year — browsers and proxies stop re-asking for them.

SERVE

Files are streamed straight from disk with range support — video/audio can seek instantly.