Skip to content
v2.7

Share links

Give access to a file to someone without an account, with an expiration.

A share link opens a file for someone who has no account in the project, without changing the file’s permissions. Under the hood, it is a file token, with an optional expiration, that goes in the URL.

In the bucket, open the file and use Share links → Create link. You can change the expiration and revoke the link later.

link-compartilhado.ts
import { Tokens } from '@owbase/node';
import { client } from './client';
// The key needs the tokens.write scope.
const tokens = new Tokens(client);
const file = { bucketId: 'invoices', fileId: '<FILE_ID>' };
// A link valid for 7 days, for people who have no account in the project.
const expires = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString();
const token = await tokens.createFileToken({ ...file, expire: expires });
// The same address that storage.getFileView({ ..., token }) from @owbase/web builds.
const link = new URL(`https://cloud.owbase.dev/v1/storage/buckets/${file.bucketId}/files/${file.fileId}/view`);
link.searchParams.set('project', '<PROJECT_ID>');
link.searchParams.set('token', token.secret);
console.log(link.toString());
  • Without expire, the link doesn’t expire; revoke it with tokens.delete({ tokenId }) when it is no longer needed.
  • tokens.list({ bucketId, fileId }) shows a file’s links.
  • In the browser, @owbase/web builds the same URL with storage.getFileView({ bucketId, fileId, token }).
Was this page helpful?