Decentralized Storage
Slik offers you the ability to upload or download files to the decentralized web as a simple drop in NPM package.
Using the slik-files package, you can enable a native upload and download experience for your users within your app. All files uploaded from the slik-files package are backed up to a decentralized storage and replicated across a globally distributed network of 10K+ nodes.
API Keys
Before getting started you would need an API key. Please follow the steps in the API key section.

Demo

You can play around with the demo app that uses the slik-files SDK at: https://slikfilesdemo.web.app

Install the library

To get started, please install the @sliksafe/slik-files package in your app.
Terminal
# Install via yarn
yarn add @sliksafe/slik-files

Upload a File

You can simply upload a file by calling the uploadFile method after initializing the library. The upload method accepts different parameters based on your requirements, specified in detail below.
React
// Import SlikFiles
import { SlikFiles } from '@sliksafe/slik-files'
// Initialize slik-files
const initParams = { apiKey: "api_key_string" }
const filesHandler = await SlikFiles.initialize(initParams)
// A file-like object with raw data. The File interface inherits from Blob.
// Assign the file object received after uploading a file.
let file: File =
// Upload a file with upload options
const uploadOptions = {
networks: ["filecoin"],
walletAddress: "0x5c14E7A5e9D4568Bb8B1ebEE2ceB2E32Faee1311",
file: file,
isEncrypted: false,
}
filesHandler.uploadFile(uploadOptions, (uploadHandle, fileId, err) => {
console.log("The unique identifier of the file uploaded: ", fileId);
if (!!err) {
console.error('Failed to upload file: ', err)
} else {
console.log("Uploading file progress: ", uploadHandle);
setUploadDownloadProgress(uploadHandle.percentage);
if (uploadHandle.status === "uploaded") {
console.log("File upload finished");
console.log("The unique identifier of the file uploaded: ", fileId);
}
}
});
Use the uploadFile method in the slik-files package with the following parameters:
File Upload Options
Data Type
Notes
networks
string[]
An array of strings for networks. The different supported network values are:
filecoin, storj, arweave, s3, gcs
You can specify as many networks that you'd like while uploading files.
file
File | Blob
The file object that is received from the web api. Read more in the MDN documentation.
walletAddress
string
Please provide the walletAddress of the user who is uploading the file. (optional)
isEncrypted
boolean
A boolean that indicates if the file is stored with end-to-end encryption on decentralized web. The specified file is encrypted on the device before it is uploaded to the decentralized storage. Default = false (optional)
After the file is uploaded the callback method is called with the unique fileId. You can use this fileId to download the file using the downloadFile method.

Download a File

You can download a file using the same fileHandler as initialized above and the downloadFile method.
React
// Download a file with download options
const downloadOptions = {
fileId: "-N-ZESm8wbGeFuxpawPi",
walletAddress: "0x5c14E7A5e9D4568Bb8B1ebEE2ceB2E32Faee1311",
}
filesHandler.downloadFile(downloadOptions, (downloadHandle, file, err) => {
console.log("Downloading file progress: ", downloadHandle.percentage);
if (downloadHandle.status === "downloaded") {
console.log("File download finished");
console.log("Downloaded file: ", file);
}
});
Use the downloadFile method in the slik-files package that takes the following parameters:
File Upload Options
Data Type
Notes
fileId
string
The unique identifier received after uploading a file.
Refer: Upload a File
walletAddress
string
Please provide the walletAddress of the user who is downloading the file. (optional)
After the file is downloaded a callback method is called with the unique fileId and the file object that was downloaded.
If the file was encrypted during upload, the slik-files package would decrypt the file after it is downloaded.

Encryption

The slik-files package automagically handles end-to-end encryption for you when you specify the isEncrypted flag during upload.
When specified, each file is encrypted using military grade AES-256 symmetric key encryption, before it is stored on decentralized storage. Also, the file is seamlessly decrypted after being downloaded and before being returned back to you in the downloadFile method.

Public Files

Encryption is disabled by default, so all files uploaded using this SDK are publicly downloadable and viewable on the decentralized web.

Pricing

slik-files has a flexible pricing plan with no upfront costs and a pay-as-you-go model, where you are charged based on the size of the files uploaded and the network that they're uploaded to.
Network
Price per GB uploaded
Filecoin
$0.006
Storj
$0.006
Arweave (permanent storage)
$14.99
S3
$0.03
Google Cloud Storage
$0.03
An additional egress cost is charged based on the size of file downloaded to handle the bandwidth used from the decentralized network of nodes.
Network
Price per GB downloaded
Filecoin
$0.01
Storj
$0.01
Arweave
$0.01
S3
$0.12
Google Cloud Storage
$0.12

Scalability

The Slik infrastructure has been designed to scale with the needs of the developer. It is currently used by thousands of users worldwide to backup terabytes of data.
Last modified 3mo ago
Copy link
On this page
Demo
Install the library
Upload a File
Download a File
Encryption
Public Files
Pricing
Scalability