@textile/hub > Buckets > pullPath
Buckets.pullPath() method
Pulls the bucket path, returning the bytes of the given file.
Signature:
pullPath(key: string, path: string, options?: {
progress?: (num?: number) => void;
}): AsyncIterableIterator<Uint8Array>;
Parameters
Parameter | Type | Description |
---|---|---|
key | string | Unique (IPNS compatible) identifier key for a bucket. |
path | string | A file/object (sub)-path within a bucket. |
options | { progress?: (num?: number) => void; } |
Returns:
AsyncIterableIterator<Uint8Array>
Example
Pull a file by its relative path and console.log the progress.
import { Buckets } from '@textile/hub'
const pullFile = async (buckets: Buckets, key: string, path: string) => {
const display = (num?: number) => {
console.log('Progress:', num)
}
buckets.pullPath(key, path, {progress: display})
}