Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The official Restash js client for uploading files directly from the browser.

Installation

npm install @restash/restash-js

Quickstart

Upload files directly from the browser to Restash.

import { createRestashUploader } from "@restash/restash-js";

const upload = createRestashUploader({ publicKey: "pk_..." });

const result = await upload(file, {
  path: "uploads/",
  onProgress: ({ percent }) => {
    console.log(`Uploading... ${percent}%`)
  },
});

console.log("File uploaded:", result.url);

If your team requires signed uploads

Create a route to generate signatures using the generateSig function with your secret key

import { generateSig } from "@restash/restash-js";

const { payload, signature } = generateSig(process.env.RESTASH_SECRET_KEY!);

return NextResponse.json({ payload, signature });

Then pass your signature route to the createRestashUploader function:

const upload = createRestashUploader({
  publicKey: "pk_...",
  handleSignature: "/api/restash/signature",
});

Do not call generateSig from the browser - this requires your secret key and must be executed in a server environment only.

Feedback & Support

Have questions or feature requests? Drop an issue on Github

About

Browser SDK for handling client-side uploads with Restash.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages