StorageClient
@human-protocol/sdk • Docs
@human-protocol/sdk / storage / StorageClient
Class: StorageClient
Deprecated
StorageClient is deprecated. Use Minio.Client directly.
Introduction
This client enables to interact with S3 cloud storage services like Amazon S3 Bucket, Google Cloud Storage and others.
The instance creation of StorageClient
should be made using its constructor:
If credentials is not provided, it uses an anonymous access to the bucket for downloading files.
Installation
npm
yarn
Code example
Constructors
new StorageClient()
new StorageClient(
params
,credentials
?):StorageClient
Storage client constructor
Parameters
• params: StorageParams
Cloud storage params
• credentials?: StorageCredentials
Optional. Cloud storage access data. If credentials is not provided - use an anonymous access to the bucket
Returns
Source
Properties
client
private
client:Client
Source
clientParams
private
clientParams:StorageParams
Source
Methods
bucketExists()
bucketExists(
bucket
):Promise
<boolean
>
This function checks if a bucket exists.
Parameters
• bucket: string
Bucket name.
Returns
Promise
<boolean
>
Returns true
if exists, false
if it doesn't.
Code example
Source
downloadFiles()
downloadFiles(
keys
,bucket
):Promise
<any
[]>
This function downloads files from a bucket.
Parameters
• keys: string
[]
Array of filenames to download.
• bucket: string
Bucket name.
Returns
Promise
<any
[]>
Returns an array of json files downloaded and parsed into objects.
Code example
Source
listObjects()
listObjects(
bucket
):Promise
<string
[]>
This function list all file names contained in the bucket.
Parameters
• bucket: string
Bucket name.
Returns
Promise
<string
[]>
Returns the list of file names contained in the bucket.
Code example
Source
uploadFiles()
uploadFiles(
files
,bucket
):Promise
<UploadFile
[]>
This function uploads files to a bucket.
Parameters
• files: any
[]
Array of objects to upload serialized into json.
• bucket: string
Bucket name.
Returns
Promise
<UploadFile
[]>
Returns an array of json files downloaded and parsed into objects.
Code example
Source
downloadFileFromUrl()
static
downloadFileFromUrl(url
):Promise
<any
>
This function downloads files from a Url.
Parameters
• url: string
Url of the file to download.
Returns
Promise
<any
>
Returns the JSON file downloaded and parsed into object.
Code example
Source
Last updated