Get a file URL

Public files can be accessed at the URL returned from saveFile or in your dashboard. Private files must first be signed by getFileUrl or include a ?token=<user access token> in the query string (the user must be added to the file).

Import the function at the top of your file

import { getFileUrl } from "swizzle-js";

Get a publicly accessible link (valid for 24 hours) for any file with getFileUrl(unsignedUrl). Returns the signed URL of the file.

const publicUrl = await getFileUrl(unsignedUrl)

You can also get the first file matching a specific fileName like this (not recommended).

const publicUrl = await getFileUrl(undefined, fileName)

Last updated