@sliksafe/slik-files v0.9.28
Decentralized Storage
Slik offers you the ability to upload or download files with end-to-end encryption 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 nodes.
Demo
You can play around with the demo app that uses the slik-files SDK at: https://slikfilesdemo.web.app
API Keys
Before getting started you would need an API key. Create an API key via the console: https://console.developers.sliksafe.com
Docs
Please see a few samples below, but you can find the detailed docs here: https://slik.gitbook.io/docs/packages/upload-and-download-files
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.
// 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);
}
}
});
Download a File
You can download a file using the same fileHandler as initialized above and the downloadFile method.
// 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);
}
});
Privacy
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
You can disable end-to-end encryption for files by simply setting the property isEncrypted as false while uploading the file.
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.
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago