Hub JS Package

Hub JS Package

  • Users
  • Buckets
  • Threads
  • Textile Docs

›Buckets

Buckets

  • Buckets.copyAuth() method
  • Buckets.withUserAuth() method
  • Buckets.withKeyInfo() method
  • Buckets.getToken() method
  • Buckets.getTokenChallenge() method
  • Buckets.setToken() method
  • Buckets.withThread() method
  • Buckets.getOrCreate() method
  • Buckets.create() method
  • Buckets.existing() method
  • Buckets.root() method
  • Buckets.links() method
  • Buckets.list() method
  • Buckets.listPath() method
  • Buckets.listPathFlat() method
  • Buckets.listIpfsPath() method
  • Buckets.movePath() method
  • Buckets.open() method
  • Buckets.pushPath() method
  • Buckets.pushPaths() method
  • Buckets.pushPathAccessRoles() method
  • Buckets.pullPath() method
  • Buckets.pullPathAccessRoles() method
  • Buckets.pullIpfsPath() method
  • Buckets.remove() method
  • Buckets.removePath() method
  • Buckets.setPath() method

Experimental

  • Archive interface
  • ArchiveDealInfo interface
  • ArchiveStatus enum

Types

  • GetOrCreateOptions interface
  • GetOrCreateResponse interface
  • CreateOptions interface
  • CreateResponse interface
  • Links interface
  • Path interface
  • PathAccessRole enum
  • PathItem interface
  • Root interface
  • BuckMetadata interface

@textile/hub > Buckets > pushPaths

Buckets.pushPaths() method

Pushes an iterable of files to a bucket.

Signature:

pushPaths(key: string, input: any, options?: PushOptions): AsyncIterableIterator<PushPathsResult>;

Parameters

ParameterTypeDescription
keystringUnique (IPNS compatible) identifier key for a bucket.
inputanyThe input array of file/stream/objects.
optionsPushOptionsPushOptions to control response stream.

Returns:

AsyncIterableIterator<PushPathsResult>

Example

Push all files in a directory to the root of a bucket

import fs from 'fs'
import path from 'path'
import util from 'util'
import glob from 'glob'
import { Buckets } from '@textile/hub'

const globDir = util.promisify(glob)

const pushMultipleFiles = async (buckets: Buckets, bucketKey: string, directory: string, globPattern: string) => {
  const options = {
    directory,
    nodir: true,
  }
  const files = await globDir(globPattern, options)
  if (files.length === 0) {
    throw Error(`No files found: ${directory}`)
  }

  let streams = []
  for (const file of files) {
      const stream = fs.createReadStream(
        path.join(directory, file), {
          highWaterMark: 1024,
        }
      )
      streams.push({
        path: file,
        content: stream,
      })
  }
  return await buckets.pushPaths(bucketKey, streams)
}

← Buckets.pushPath() methodNext →
  • Buckets.pushPaths() method
  • Parameters
  • Example
Hub JS Package
Docs
Getting StartedThreadDBBuckets
Resources
All DocumentationProject SlackBlog
More
GitHubStar
Follow @textileio