uplink-js
ES9+ compatible Storj bindings for Node, for use with Tardigrade.
Usage
Example
const uplink = ;async {// parse accessconst access = await uplink;// open projectconst project = await access;// initiate file downloadconst download = await project;// read chunks to program outputfor {processstdout;˜}};
Example with streams
// initiate file downloadconst download = await project;download;
API
Project
Promise
<Download
> project.downloadObject(bucket, path)
Returns a Promise which resolves to a Download
object.
const download = await project;
Promise
<Upload
> project.uploadObject(bucket, path)
Returns a Promise which resolves to an Upload
object.
const upload = await project;
Async Iterable
<StorjObject
> project.listObjects(bucket, options)
Iterates through all objects in a bucket.
Promise
project.deleteObject(bucket, path)
Delete an object.
options
prefix
Specifies from which prefix to list files.
type: string
default: '/'
recursive
type: bool
default: false`
for await const object of projectconsole;
Download
Implements asyncIterable which yields Buffers as the download is streamed.
for {console}
ReadableStream
download.stream()
Returns a ReadableStream compatible with Node.js libraries and frameworks.
download;
Promise
<Buffer
> download.buffer()
Returns a Promise that resolves to a Buffer containing the entire download.
const buf = await download;console
Upload
Promise
upload.iterable(iterable)
Uploads from an iterable that yields buffers.
{Buffer;await ;Buffer;}await upload;
WritableStream
upload.stream()
Returns a WritableStream compatible with Node.js libraries and frameworks.
fs;