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.
From the console
Section titled “From the console”In the bucket, open the file and use Share links → Create link. You can change the expiration and revoke the link later.
From the server
Section titled “From the server”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 withtokens.delete({ tokenId })when it is no longer needed. tokens.list({ bucketId, fileId })shows a file’s links.- In the browser,
@owbase/webbuilds the same URL withstorage.getFileView({ bucketId, fileId, token }).
Was this page helpful?Thanks for your feedback.