0.0.6 • Published 3 years ago

node-red-contrib-minio-all v0.0.6

Weekly downloads
10
License
Apache-2.0
Repository
github
Last release
3 years ago

node-red-contrib-minio-all

NodeRed Node for common MinIO operations, by Colin Payne.

This node utilises the MinIO JavaScript API (please see https://docs.min.io/docs/javascript-client-api-reference.html).

Please Note: This set of nodes (and associated support information) is a work in progress.

The Bucket Notification Operation setBucketNotification is being worked on, and is not currently functioning correctly.

2021/01/29 - Version: 0.0.6getObject now working; edits by @macanfa - thank you!

2020/05/06 - Version: 0.0.5getPartialObject now working as expected, and README updated accordingly.

2020/04/29 - Version: 0.0.4listenBucketNotification now extended to include defined Supported Event Types.

MinIO Operations

Bucket OperationsFile Object OperationsObject Operations
makeBucketfGetObjectgetObject
listBucketsfPutObjectgetPartialObject
bucketExistsputObject
removeBucketcopyObject
listObjectsstatObject
listObjectsV2removeObject
listObjectsV2WithMetadataremoveObjects
listIncompleteUploadsremoveIncompleteUpload
Presigned OperationsBucket Notification OperationsBucket Policy Operations
presignedUrlgetBucketNotificationgetBucketPolicy
presignedGetObjectsetBucketNotificationsetBucketPolicy
presignedPutObjectremoveAllBucketNotification
presignedPostPolicylistenBucketNotification

Passing in parameters

For each operation, parameters can either be set in the Edit Node dialogue, or passed in to the node via the node input. Parameters passed in will override any parameters set in the Edit Node dialogue.

The Operation in each case can be passed in to the node by setting the appropriate incoming value of msg.operation

Bucket Operations

1. makeBucket

Description

Creates a new bucket.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket to be created
regionRegionregion(msg.region)Region where the bucket is to be created. (optional)

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the bucket was created, e.g. {"makeBucket":true}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

2. listBuckets

Description

List all buckets.

Parameters

No parameters required.

Node Outputs

NameDescription
OutputThe node will output a JS object in the form {"listBuckets":[...]} containing an array of objects in the form {"name":"bucketname","creationDate": "yyyy-mm-ddThh:mm:ss.sssZ"} for each bucket.
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

3. bucketExists

Description

Checks if a bucket exists.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket to be checked.

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the bucket exists, e.g. {"bucketExists":true}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

4. removeBucket

Description

Removes a bucket.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket to be removed.

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the bucket has been removed, e.g. {"removeBucket":true}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

5. listObjects

Description

Lists all objects in a bucket.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket for which the objects listing is required.
prefixPrefixprefix(msg.prefix)The prefix of the objects that should be listed. (optional).
recursiveRecursiverecursive(msg.recursive)true indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default false).

Node Outputs

NameDescription
OutputThe node will output a JS object in the form {"listObjects":[...]} containing an array of JS objects in the form {"name":"objectname", "lastModified": "yyyy-mm-ddThh:mm:ss.sssZ", "etag":"etagstring", "size":1234} for each object returned.
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

6. listObjectsV2

Description

Lists all objects in a bucket using S3 listing objects V2 API.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket for which the objects listing is required.
prefixPrefixprefix(msg.prefix)The prefix of the objects that should be listed. (optional).
recursiveRecursiverecursive(msg.recursive)true indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default false).
startAfterStart AfterstartAfter(msg.startAfter)Specifies the object name to start after, when listing objects in a bucket. (optional).

Node Outputs

NameDescription
OutputThe node will output a JS object in the form {"listObjectsV2":[...]} containing an array of JS objects in the form {"name":"objectname", "lastModified": "yyyy-mm-ddThh:mm:ss.sssZ", "etag":"etagstring", "size":1234} for each object returned.
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

7. listObjectsV2WithMetadata

Description

Lists all objects and their metadata in a bucket using S3 listing objects V2 API.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket for which the objects listing is required.
prefixPrefixprefix(msg.prefix)The prefix of the objects that should be listed. (optional).
recursiveRecursiverecursive(msg.recursive)true indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default false).
startAfterStart AfterstartAfter(msg.startAfter)Specifies the object name to start after, when listing objects in a bucket. (optional).

Node Outputs

NameDescription
OutputThe node will output a JS object in the form {"listObjectsV2WithMetadata":[...]} containing an array of JS objects in the form {"name":"objectname", "lastModified": "yyyy-mm-ddThh:mm:ss.sssZ", "etag":"etagstring", "size":1234, "metadata":{...} } for each object returned.
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

8. listIncompleteUploads

Description

Lists partially uploaded objects in a bucket.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
prefixPrefixprefix(msg.prefix)Prefix of the object names that are partially uploaded. (optional).
recursiveRecursiverecursive(msg.recursive)true indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default false).

Node Outputs

NameDescription
OutputThe node will output a JS object in the form {"listIncompleteUploads":[...]} containing an array of JS objects in the form {"key":"objectname", "uploadId": "uploadidstring", "size":1234} for each object returned.
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

File Object Operations

1. fGetObject

Description

Downloads and saves the object as a file in the local filesystem.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
filefileobjectName(msg.objectName)Name of the object.
pathPathfilePath(msg.filePath)Path on the local filesystem to which the object data will be written.

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the object could be downloaded as a file, e.g. {"fGetObject":true}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

2. fPutObject

Description

Uploads contents from a file to objectName.

The maximum size of a single object is limited to 5TB. fPutObject transparently uploads objects larger than 64MiB in multiple parts. Uploaded data is carefully verified using MD5SUM signatures.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
filefileobjectName(msg.objectName)Name of the object.
pathPathfilePath(msg.filePath)Path of the file to be uploaded.
metaDataMetaDatametaData(msg.metaData)Metadata of the object (optional).

Node Outputs

NameDescription
OutputThe node will output a JS object, containing confirmation as to whether or not the file object was successfully uploaded, and, if successful, an etag value for the uploaded file object, e.g. {"fPutObject":true,"etag":"etagvaluestring"}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

Object Operations

1. getObject

Description

Downloads an object as a stream.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
fileObjectobjectName(msg.objectName)Name of the object.

Node Outputs

NameDescription
OutputThe node will output a JS object. {"getObject":true,"objectData":Buffer,"opjectSize":size-in-bytes}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

2. getPartialObject

Description

Downloads the specified range bytes of an object as a stream.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
fileObjectobjectName(msg.objectName)Name of the object.
offsetOffsetoffset(msg.offset)Offset of the object from where the stream will start.
lengthLengthlength(msg.length)Length of the object that will be read in the stream (optional, if not specified we read the rest of the file from the offset).

Node Outputs

NameDescription
OutputThe node will output a JS object, containing confirmation as to whether or not thepartial object (chunk) was successfully downloaded, and, if successful, a buffer array for the downloaded partial object stream, e.g. { "getPartialObject": true, "chunk": [...] }
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

3.putObject

Description

Uploads an object from a stream/Buffer.

The maximum size of a single object is limited to 5TB. putObject transparently uploads objects larger than 64MiB in multiple parts. Uploaded data is carefully verified using MD5SUM signatures.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
fileObjectobjectName(msg.objectName)Name of the object.
streamStreamstream(msg.stream)Readable stream.
sizeSizesize(msg.size)Size of the object (optional).
metaDataMeta DatametaData(msg.metaData)Meta data of the object (optional).

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the object PUT operation was successful, including (if appropriate) the etag reference of the object, , e.g. {"bucketExists":true, "etag":etagstring}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

4. copyObject

Description

Copy a source object into a new object in the specified bucket.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
fileObjectobjectName(msg.objectName)Name of the object.
sourceObjectSourcesourceObject(msg.sourceObject)Path of the file to be copied, in the format bucketname/objectname
sizeSizesize(msg.size)Conditions to be satisfied before allowing object copy.
tagETagsetMatchEtag(msg.setMatchEtag)Conditions to be satisfied before allowing object copy.
tagExcept ETagsetMatchEtagExcept(msg.setMatchEtagExcept)Conditions to be satisfied before allowing object copy.
calendarModifiedsetModified(msg.setModified)Conditions to be satisfied before allowing object copy.
metaDataMetaDatasetReplaceMetadataDirective(msg.setReplaceMetadataDirective)Conditions to be satisfied before allowing object copy.
calendarUnmodifiedsetUnmodified(msg.setUnmodified)Conditions to be satisfied before allowing object copy.

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the object has been copied, e.g. {"copyObject":true}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

5. statObject

Description

Lists all objects in a bucket.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket for which the objects listing is required.
prefixPrefixprefix(msg.prefix)The prefix of the objects that should be listed. (optional).
recursiveRecursiverecursive(msg.recursive)true indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default false).

Node Outputs

NameDescription
OutputThe node will output a JS object in the form {"listObjects":[...]} containing an array of JS objects in the form {"name":"objectname", "lastModified": "yyyy-mm-ddThh:mm:ss.sssZ", "etag":"etagstring", "size":1234} for each object returned.
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

6. removeObject

Description

Lists all objects in a bucket using S3 listing objects V2 API.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket for which the objects listing is required.
prefixPrefixprefix(msg.prefix)The prefix of the objects that should be listed. (optional).
recursiveRecursiverecursive(msg.recursive)true indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default false).
startAfterStart AfterstartAfter(msg.startAfter)Specifies the object name to start after, when listing objects in a bucket. (optional).

Node Outputs

NameDescription
OutputThe node will output a JS object in the form {"listObjectsV2":[...]} containing an array of JS objects in the form {"name":"objectname", "lastModified": "yyyy-mm-ddThh:mm:ss.sssZ", "etag":"etagstring", "size":1234} for each object returned.
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

7. removeObjects

Description

Removes all objects in a specified bucket matching an optional prefix value, or a defined list of object names.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
listObjects ListobjectsList(msg.objectsList)Explicit list of objects in the bucket to be removed (Optional). Should be provided as an array of object names, e.g. [ "object_01", "object_02", "object_03" ]. If left blank, then all objects in the specified bucket will be removed (subject to any value specified in the prefix field).
prefixPrefixprefix(msg.prefix)The prefix of the objects that should be removed (Optional). If no prefix is provided, then all objects within the specified bucket will be removed, unless an explicit list of objects is provided in the Objects List field.

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the list of objects have been removed, e.g. {"removeObjects":true}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

8. removeIncompleteUpload

Description

Lists partially uploaded objects in a bucket.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
prefixPrefixprefix(msg.prefix)Prefix of the object names that are partially uploaded. (optional).
recursiveRecursiverecursive (msg.recursive)true indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default false).

Node Outputs

NameDescription
OutputThe node will output a JS object in the form {"listIncompleteUploads":[...]} containing an array of JS objects in the form {"key":"objectname", "uploadId": "uploadidstring", "size":1234} for each object returned.
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

Presigned Operations

1. presignedURL

Description

Generates a presigned URL for the provided HTTP method, 'httpMethod'.

Browsers/Mobile clients may point to this URL to directly download objects even if the bucket is private. This presigned URL can have an associated expiration time in seconds after which the URL is no longer valid. The default value is 7 days.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
fileObjectobjectName(msg.objectName)Name of the object.
expiryExpiryexpiry(msg.expiry)Expiry time in seconds. Default value is 7 days. (optional)
paramsParamsreqParams(msg.reqParams)Request parameters. (optional)
calendarIssue DaterequestDate(msg.requestDate)A date object, the url will be issued at. Default value is now. (optional)

Node Outputs

NameDescription
OutputIf successful, the node will output a JS object, containing the generated presigned URL, e.g. { "presignedURL": presignedUrl }
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

2. presignedGetObject

Description

Generates a presigned URL for HTTP GET operations. Browsers/Mobile clients may point to this URL to directly download objects even if the bucket is private. This presigned URL can have an associated expiration time in seconds after which the URL is no longer valid. The default value is 7 days.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
fileObjectobjectName(msg.objectName)Name of the object.
expiryExpiryexpiry(msg.expiry)Expiry time in seconds. Default value is 7 days. (optional)
headersHeadersrespHeaders(msg.respHeaders)Response headers to override (optional)
calendarIssue DaterequestDate(msg.requestDate)A date object, the url will be issued at. Default value is now. (optional)

Node Outputs

NameDescription
OutputIf successful, the node will output a JS object, containing the generated presigned GET object URL, e.g. { "presignedURL": presignedUrl }
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

3. presignedPutObject

Description

Generates a presigned URL for HTTP PUT operations. Browsers/Mobile clients may point to this URL to upload objects directly to a bucket even if it is private. This presigned URL can have an associated expiration time in seconds after which the URL is no longer valid. The default value is 7 days.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
fileObjectobjectName(msg.objectName)Name of the object.
expiryExpiryexpiry(msg.expiry)Expiry time in seconds. Default value is 7 days. (optional)

Node Outputs

NameDescription
OutputIf successful, the node will output a JS object, containing the generated presigned PUT object URL, e.g. { "presignedURL": presignedUrl }
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

4. presignedPostPolicy

Description

Allows setting policy conditions to a presigned URL for POST operations. Policies such as bucket name to receive object uploads, key name prefixes, expiry policy may be set.

Parameters

NameParameter(passed in as)Description
bucketBucketpolicy.setBucket(msg.policy.setBucket)Policy restricting bucket for upload (optional).
fileKeypolicy.setKey(msg.policy.setKey)Policy restricting object Key for upload (optional).
Key Prefixpolicy.setKeyStartsWith(msg.policy.setKeyStartsWith)Policy restricting object Key prefix for upload (optional).
expiryExpirypolicy.setExpires(msg.policy.setExpires)Expiry time of the policy, in seconds (optional).
typeTypepolicy.setContentType(msg.policy.setContentType)Policy restricting content type for upload, e.g. text/plain (optional).
sizeFromSize: Frompolicy.setContentLengthRange(msg.policy.setContentLengthRange.from)The lower end of the range of content length for the upload, in bytes, e.g. 1024 (optional).
sizeToSize: Topolicy.setContentLengthRange(msg.policy.setContentLengthRange.to)The upper end of the range of content length for the upload, in bytes, e.g. 1024*1024 (optional).

Node Outputs

NameDescription
OutputIf successful, the node will output a JS object, containing the details of the submitted policy, e.g. { "presignedPostPolicy": { "postURL": url, "formData": {...} } }
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

Bucket Notification Operations

For each operation, paramenters can either be set in the Edit Node dialogue, or passed in to the node via the node input. Parameters passed in will override any parameters set in the Edit Node dialogue.

The bucket Operation can be passed in to the node by setting the appropriate incoming value of msg.operation

1. getBucketNotification

Description

Creates a new bucket.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket to be created.
regionRegionregion(msg.region)Region where the bucket is to be created. (optional)

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the bucket was created, e.g. {"makeBucket":true}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

2. setBucketNotification

Description

List all buckets.

Node Outputs

NameDescription
OutputThe node will output a JS object in the form {"listBuckets":[...]} containing an array of objects in the form {"name":"bucketname","creationDate": "yyyy-mm-ddThh:mm:ss.sssZ"} for each bucket.
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

3. removeAllBucketNotification

Description

Checks if a bucket exists.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket to be checked.

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the bucket exists, e.g. {"bucketExists":true}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

4. listenBucketNotification

Description

Removes a bucket.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket to be removed.

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the bucket has been removed, e.g. {"removeBucket":true}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

Bucket Policy Operations

For each operation, paramenters can either be set in the Edit Node dialogue, or passed in to the node via the node input. Parameters passed in will override any parameters set in the Edit Node dialogue.

The bucket Operation can be passed in to the node by setting the appropriate incoming value of msg.operation

1. getBucketPolicy

Description

Get the bucket policy associated with the specified bucket. If objectPrefix is not empty, the bucket policy will be filtered based on object permissions as well.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the bucket policy exists, and if it does, the details of the policy, e.g. {"getBucketPolicy":true, "policy":{...} }
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

2. setBucketPolicy

Description

Set the bucket policy on the specified bucket. bucketPolicy is detailed here.

Parameters

NameParameter(passed in as)Description
bucketBucketbucketName(msg.bucketName)Name of the bucket.
policyPolicybucketPolicy(msg.bucketPolicy)Bucket policy.

Node Outputs

NameDescription
OutputThe node will output confirmation, in the form of a JS object, as to whether or not the bucket policy has been set, e.g. {"setBucketPolicy":true}
ErrorAny errors received in response to the request will be passed to the node's 'Error' output.

Copyright © 2020 Colin Payne

0.0.6

3 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago