StorageClient
@human-protocol/sdk / storage / StorageClient
Class: StorageClient
Defined in: storage.ts:63
Deprecated
StorageClient is deprecated. Use Minio.Client directly.
Introduction
This client enables interacting 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 are not provided, it uses anonymous access to the bucket for downloading files.
Installation
npm
yarn
Code example
Constructors
new StorageClient()
new StorageClient(
params
,credentials
?):StorageClient
Defined in: storage.ts:73
Storage client constructor
Parameters
params
Cloud storage params
credentials?
Optional. Cloud storage access data. If credentials are not provided - use anonymous access to the bucket
Returns
Methods
bucketExists()
bucketExists(
bucket
):Promise
<boolean
>
Defined in: storage.ts:262
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
downloadFiles()
downloadFiles(
keys
,bucket
):Promise
<any
[]>
Defined in: storage.ts:112
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
listObjects()
listObjects(
bucket
):Promise
<string
[]>
Defined in: storage.ts:292
This function lists 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
uploadFiles()
uploadFiles(
files
,bucket
):Promise
<UploadFile
[]>
Defined in: storage.ts:198
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 uploaded file metadata.
Code example
downloadFileFromUrl()
static
downloadFileFromUrl(url
):Promise
<any
>
Defined in: storage.ts:146
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 an object.
Code example
Last updated