Skip to content

Documentation

TypeScript SDK: Storage: files and links

ctx.storage(code) accesses a configured storage connection. All file and link operations are asynchronous.

Each example is a separate fragment inside async function run(ctx: Akmelo.Context): Promise<void>. Use await only for methods whose signature returns a Promise.

Methods

putFromUrl

ctx.storage('media').putFromUrl(url, key, mime) → Promise<object>

Copies a file from an allowed URL to the selected storage and returns a plain object with saved-file data.

const result = await ctx.storage('media').putFromUrl('https://example.com/image.jpg', 'images/item.jpg');

put

ctx.storage('media').put(key, content, mime) → Promise<object>

Saves content in the configured storage. Returns a plain storage response object, not a PHP StoredFile instance.

const result = await ctx.storage('media').put('reports/summary.txt', 'Ready');

exists

ctx.storage('media').exists(key) → Promise<boolean>

Check whether an object exists under a key.

const result = await ctx.storage('media').exists('reports/summary.txt');

url

ctx.storage('media').url(key, ttlSeconds) → Promise<string>

Get a temporary signed link to an object.

const result = await ctx.storage('media').url('reports/summary.txt');