Files upload Node.js

Upload files from withing your Node.js app.

Smash is a file upload API service, that provides the world best multiple files upload and transfer API solution without worrying about size limits.

Features

The files upload Node.js SDK helps you perform the following tasks:

  • Upload features

    • Add a file uploading capability to your website, app, Saas, etc.

    • Upload files of any type and up to 5 TB in size

    • Upload multiple files or folders in one go

    • Multipart uploading for large files

    • Track upload jobs

    • Speed up the uploading with the acceleration network consisting of 300+ servers, powered by AWS in 9 regions around the world

  • Download features

    • Download files from an URL

    • Show image, video and audio previews

    • Custom the download page with a logo and a background

    • Track downloads

    • Speed up the downloading with Cloudfront CDN

  • Storage

    • Files are stored from 1 to 30 days

  • Security

    • All uploads are signed

    • Your uploads are continually scanned for infected or malicious files using ClamAV, a high-performance antivirus engine

    • Add a password protection on transfers

    • All your data are encrypted in-flight and at-rest (256-bit AES and SSL/TLS encryption)

Quick start

Install the Smash 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 SDK installed, you can start to create your first transfer from the example code below:

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);
});

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 destination file, ex: /dummyFiles/dummy.zip",
});

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

Advanced examples

After you made your first upload with the “basic” example, you can start to make a new upload with more properties with the code below:

import { SmashUploader } from "@smash-sdk/uploader";

const su = new SmashUploader({ region: "eu-west-3", token: "Put your api key here" });
const files = [
    "./dummyFiles/dummy1.png",
    "./dummyFiles/dummy2.png",
    "./dummyFiles/dummy3.txt",
];
su.upload({
    files,
    title: 'my-transfer',
    description: 'my-description',
    password: 'my-password',
    availabilityDuration: 86400,
    teamId: '*****-******-******-********-*7',
    customization: {
        logo: 'https://my-logo-url.com',
        background: 'https://my-background-url.com',
    },
    preview: 'Full',
}).then(transfer => {
    console.log("Transfer", transfer);
}).catch(error => {
    console.log("Error", error);
});

region

title

description

password

availabilityDuration

teamId

customization.logo

customization.background

preview

This is the region where your files will be stored. We do have servers in 9 regions around the world and they are organized in regions. You’ll find below the list of the 9 regions available. It is good practice to choose the region that is closest to you because the latency of the transfer is lower, which results in better upload speeds.

Values:
us-east-1 (US East - N. Virginia)
us-east-2 (US East - Ohio)
us-west-1 (US West - N. California)
us-west-2 (US West - Oregon)
ca-central-1 (Canada - Central)
eu-west-1 (Europe - Ireland)
eu-west-2 (Europe - London)
eu-west-3 (Europe - Paris)
eu-central-1 (Europe - Frankfurt)

Default:
eu-west-3

You can optionally specify a title to your transfer.

Optional

You can optionally specify a description to your transfer.

You can optionally specify a password required for downloading the file.

This is the number of seconds the file is available for download. The minimum value is 5 minutes, the maximum value is 30 days. The unit has to be in seconds.

Default:
86400 (7 days)

You can optionally specify a teamId. When using a teamId, the download URL will be customized, and you will be able to use a customized background and logo. To create a teamID, go to your developer account settings, in the "Domain" section. Click on the "Create” button, then copy/paste the teamId.

The logo you'd like to add on your transfer. The logo will be display on the download page. You'll be able to add your own by an URL. The recommanded size of your logo is 300*300px.

The backgound you'd like to add on your transfer. The backgound will be display on the download page. It can be an image or a video. You'll be able to add your own image by an URL. The recommanded size of your image is 2000*1125px. If you want to add a video in background, you have to insert a YouTube URL or a Vimeo URL.

Choose if you'd like to show image, video and audio previews on the downlaod page. You'll be able to enable/disable the preview.

Values:
Full
None

Default:
Full

After you made your first download with the “basic” example, you can start to make a new download with more properties with the code below:

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 destination file, ex: /dummyFiles/dummy.zip",
    enableOverride: true,
});

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

Docs / Integrations / Node.js



A - Advanced upload configuration

PARAMETERS

DESCRIPTION

Required


Optional




Optional

Optional

Optional

B - Advanced download configuration

Optional

Optional




ON THIS PAGE

Intro
Features
Quick start
Advanced examples

A - Make your first upload

B - Make your first download

Optional