Save a file
Import the function at the top of your file
import { saveFile } from "swizzle-js";
Upload a file to storage with saveFile(fileName, fileData, isPrivate?, allowedUsers?)
fileName
is the filename (searchable later, does not have to be unique). Include the file extension.fileData
is the data you'd like to upload.isPrivate
if this is set to true, the URL will not be accessible unless signed by the getFile function or the user is in allowedUsers.allowedUsers
is an array of userIds. If these users pass their access token in the Authorization header or under the token parameter in the query string, they will be allowed to access the file automatically.
Returns the hosted file URL (unsigned)
const url = await saveFile(fileName, fileData, isPrivate, allowedUsers)
Last updated