Skip to main content

Overview

The CDN API allows you to upload and retrieve files from the Lua CDN. Files are stored securely and can be accessed by their unique file ID.

Methods

upload

Uploads a file to the CDN.
Parameters: Returns: Promise<string> - The unique file ID Example:

get

Retrieves a file from the CDN by its ID.
Parameters: Returns: Promise<File> - The File object with name, type, and size properties Example:

Use Cases

Store User Uploads

Retrieve and Process Files

Use with AI for Image Analysis

Re-upload Files

Since CDN.get() returns a File object, you can easily re-upload files:

File Properties

The File object returned by CDN.get() has these properties: And these methods:

Supported File Types

The CDN supports all file types including:
  • Images: PNG, JPEG, GIF, WebP, SVG
  • Documents: PDF, DOC, DOCX, TXT
  • Data: JSON, CSV, XML
  • Audio/Video: MP3, MP4, WAV
  • Archives: ZIP, TAR
Images are automatically optimized with WebP compression while maintaining quality.

Best Practices

Include meaningful names when creating Files:
Always specify the correct MIME type:
Save file IDs in your data for later retrieval:
Always handle potential errors:

Complete Example

If a CDN upload or retrieval isn’t working as expected, log file metadata to inspect what was returned:
Then run lua logs --type skill --limit 5 after a test message. See the Debugging Skills guide for the full workflow.