StorageClient
@human-protocol/sdk / Modules / storage / StorageClient
Class: StorageClient
storage.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
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new StorageClient(params
, credentials?
): StorageClient
Storage client constructor
Parameters
Name | Type | Description |
---|---|---|
|
| Cloud storage params |
|
| Optional. Cloud storage access data. If credentials is not provided - use an anonymous access to the bucket |
Returns
Defined in
Properties
client
• Private
client: Client
Defined in
clientParams
• Private
clientParams: StorageParams
Defined in
Methods
bucketExists
▸ bucketExists(bucket
): Promise
<boolean
>
This function checks if a bucket exists.
Parameters
Name | Type | Description |
---|---|---|
|
| Bucket name. |
Returns
Promise
<boolean
>
Returns true
if exists, false
if it doesn't.
Code example
Defined in
downloadFiles
▸ downloadFiles(keys
, bucket
): Promise
<any
[]>
This function downloads files from a bucket.
Parameters
Name | Type | Description |
---|---|---|
|
| Array of filenames to download. |
|
| Bucket name. |
Returns
Promise
<any
[]>
Returns an array of json files downloaded and parsed into objects.
Code example
Defined in
listObjects
▸ listObjects(bucket
): Promise
<string
[]>
This function list all file names contained in the bucket.
Parameters
Name | Type | Description |
---|---|---|
|
| Bucket name. |
Returns
Promise
<string
[]>
Returns the list of file names contained in the bucket.
Code example
Defined in
uploadFiles
▸ uploadFiles(files
, bucket
): Promise
<UploadFile
[]>
This function uploads files to a bucket.
Parameters
Name | Type | Description |
---|---|---|
|
| Array of objects to upload serialized into json. |
|
| Bucket name. |
Returns
Promise
<UploadFile
[]>
Returns an array of json files downloaded and parsed into objects.
Code example
Defined in
downloadFileFromUrl
▸ downloadFileFromUrl(url
): Promise
<any
>
This function downloads files from a Url.
Parameters
Name | Type | Description |
---|---|---|
|
| Url of the file to download. |
Returns
Promise
<any
>
Returns the JSON file downloaded and parsed into object.
Code example
Defined in
Last updated