Installation
Basic usage
Here’s a simple example of how to use the Restash client SDK to upload files directly from the browser.Creating the uploader
ThecreateRestashUploader function creates an uploader instance.
lib/restash.ts
string
required
Your Restash public API key. This is required to authenticate the upload request.
string
The URL of your server route that returns a signature and payload. Only required if your team has signature enforcement enabled. Learn more.
Using the uploader
You can import your uploader instance and use it to upload files.File | Blob
required
The file or blob to upload.
UploadOptions object
An object with the following optional properties:
UploadResult object
The information about the uploaded file.
Generating signatures
If your team has signature enforcement enabled, you need to generate a signature for each upload request. You can do this by creating a server route that returns a signature and payload using thegenerateSig function from the Restash client SDK. Generating signatures needs to be done on the server. You can then pass this route to the createRestashUploader so that it can be called when needed.
/api/restash/signature/route.ts
string
required
Your Restash secret API key. This is required to generate the signature.