Quick start with Node.js

Make your first files upload and download with Node.js SDK.

Once you have created your Smash Account for free and generated your first API Key, in minutes through our documentation, install the Smash Uploader and/or the Smash Downloader Node.js server-side SDK to get access to Smash APIs from applications written in Node.js.

Make your first upload

Install the Smash Uploader Node.js server-side SDK to get access to Smash APIs from applications written in Node.js.

We recommend installing the library with npm, a package manager for Node.

npm install @smash-sdk/uploader

Now that you have the Node.js Uploader SDK installed, you can start to create your first transfer from the example code below:

Code example for creating a files upload:

Replace "Put an API key here" with your own.

import { SmashUploader } from "@smash-sdk/uploader";
const su = new SmashUploader({ region: "eu-west-3", token: "Put an API key here" })
const files = [
    "./dummyFiles/dummy1.jpeg",
    "./dummyFiles/dummy2.mp4",
    "./dummyFiles/dummy3.pdf",
];
su.upload({ files }).then(transfer => {
    console.log(transfer);
}).catch(error => {
    console.log(error);
});

Docs / Quick start / Node.js



Make your first download

Once you have created your first files upload, you can start to create your first files download by installing the Smash Downloader Node.js server-side SDK to get access to Smash APIs from applications written in Node.js.

We recommend installing the library with npm, a package manager for Node.

npm install @smash-sdk/downloader

Now that you have the Downloader Node.js SDK installed, you can start to make your first transfer download from the example code below:

Code example for making a files download:

Replace "Put an API key here" with your own.

import * as fs from 'fs'
import { SmashDownloader } from "@smash-sdk/downloader";

const sd1 = new SmashDownloader({
    token: "Put your api key",
    transferId: "Put a transfer id here",
    path: "Path to file, ex: /dummyFiles/dummy.zip",
    //enableOverride: true, // support for override
});

sd1.download().then(downloadedItem => {
    console.log("Download", downloadedItem);
}).catch(error => {
    console.log("Error", error);
});

ON THIS PAGE

Make your first upload
Make your first download