Skip to main content

Installation

Basic usage

Here’s a simple example of how to use the Restash client SDK to upload files directly from the browser.
For more usage examples, check out:

Creating the uploader

The createRestashUploader function creates an uploader instance.
lib/restash.ts
It accepts an options object with the following properties:
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.
It accepts the following parameters:
File | Blob
required
The file or blob to upload.
UploadOptions object
An object with the following optional properties:
A successful upload will respond with the following:
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 the generateSig 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
It accepts the following parameters:
string
required
Your Restash secret API key. This is required to generate the signature.

Additional resources

NPM package

Download and install the Restash js client SDK from NPM

Source code

View the complete source code for the Restash client SDK