English
Files
Kaiten is migrating file routes to restricted access. Use restrictedAccessCardFiles, restrictedAccessCommentFiles, and restrictedAccessCustomPropertyFiles. These take UUIDs for cards and related entities. See Kaiten's migration guide.
In these examples, client is a KaitenClient instance from the first request.
Upload
ts
const uploaded = await client.restrictedAccessCardFiles.attachFileToCard(
'card-uuid',
new Blob(['report'], {type: 'text/plain'}),
{filename: 'report.txt'},
);
console.log(uploaded.id);The client creates multipart/form-data with its boundary. Pass a Blob and, optionally, filename; do not encode the file as JSON.
Get a temporary link
ts
const file = await client.restrictedAccessCardFiles.getCardFile(
'card-uuid',
uploaded.id,
);
const redirect = await client.restrictedAccessCardFiles.getCardFile(
'card-uuid',
uploaded.id,
true,
);
console.log(file.url);
console.log(redirect.location);redirect: true returns { location: string } from the Location header; the client does not follow the redirect. Download the temporary URL with a separate request and without the Kaiten token. The legacy client.cardFiles.attachFileToCard remains available with @deprecated.
See the REST reference for all card, comment, and property file operations.