JavaScript SDK: Documents: opening files
ctx.documents() reads allowed files. Loading is asynchronous; methods on a loaded Document run locally.
Each example is a separate fragment inside async function run(ctx). Use await only for methods whose signature returns a Promise.
Methods
fromUrl
ctx.documents().fromUrl(url, name) → Promise<Document>
Download a file up to 10 MiB through the current source's network settings. Address, redirect, robots.txt, request-rate, and proxy rules still apply. The name is taken from the URL; supply it as the second argument if the URL has no extension.
const result = await ctx.documents().fromUrl(ctx.param('file_url', 'https://example.com/report.csv'), 'report.csv');
fromBytes
ctx.documents().fromBytes(content, name) → Promise<Document>
Parse bytes you already have, up to 8 MiB. The name helps identify text and older Office formats; the service also checks the content signature.
const result = await ctx.documents().fromBytes('sku,price\nA-1,1250', 'report.csv');
coordinates
ctx.documents().coordinates() → SheetCoordinates
Excel addressing helpers that do not load a document or make a network request.
const result = ctx.documents().coordinates();