1.0.4 • Published 6 years ago
@arweave-cdn/uploader v1.0.4
Arweave uploader
Tiny SDK to upload assets to Arweave permaweb, it's a core uploader used in the following plugins:
- Arweave Uploader Webpack Plugin (https://github.com/bonifaty/webpack-arweave)
Installation
Using npm:
npm install @arweave-cdn/uploader --save Usage
import { ArweaveUploader } from '@arweave-cdn/uploader';
const arweaveUploader = new ArweaveUploader();
await arweaveUploader.init('/absolute/path/to/arweave-wallet-key-file.json');
const filesToUpload = [
'/Users/andrew/web3/index.html',
'/Users/andrew/web3/styles.css',
'/Users/andrew/web3/images/unicorn_llama.jpg',
];
await arweaveUploader.uploadAssets(filesToUpload, '/Users/andrew/web3/', 'index.html');Methods
init(walletKeyFilepath, arweaveApiConfig)
walletKeyFilePath(required): Absolute file path to arweave wallet key filearweaveApiConfig(optional): Arweave API config object to use for Arweave connection. Defaults to following values:
{
host: 'arweave.net',// Hostname or IP address for a Arweave host
port: 443, // Port
protocol: 'https', // Network protocol http or https
timeout: 20000, // Network request timeouts in milliseconds
logging: false, // Enable network request logging
}uploadAssets(filesToUpload, rootPath, indexFile, verbose)
filesToUpload(required): Array of files (with absolute file paths) which need to be uploadedrootPath(required): Path to the directory which is being uploadedindexFile(optional): Index file (relative path), e.g. index.htmlverbose(optional): Boolean field to enable / disable progress messages, defaults to true