Package Exports
- @sliksafe/slik-files
- @sliksafe/slik-files/build/index.esm.js
- @sliksafe/slik-files/build/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sliksafe/slik-files) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Upload & Download Files
Slik offers you the ability to upload or download files with end-to-end encryption 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.
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-filesUpload 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 = 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 = {
isEncrypted: false,
network: "filecoin",
walletAddress: "0x5c14E7A5e9D4568Bb8B1ebEE2ceB2E32Faee1311",
file: file,
}
filesHandler.uploadFile(uploadOptions, (fileId, err) => {
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, (fileId, file, err) => {
console.log("The unique identifier of the downloaded file: ", fileId);
});Privacy
Each file uploaded using the slik-files package is encrypted using AES-256 military grade encryption. The key used to encrypt the file is constructed on the client using the API Key and the a unique identifier constructed using the walletAddress.
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.