Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# node-red-contrib-cos

A <a href="http://nodered.org" target="_new">Node-RED</a> node to store, delete, restore and query objects from the
<a href="https://cloud.ibm.com/docs/services/cloud-object-storage/about-cos.html#about-ibm-cloud-object-storage" target="_new">IBM Cloud Object Storage</a> service. This service is a S3 like object storage hosted on the <a href="https://cloud.ibm.com" target="_new">IBM Cloud</a>.
A set of <a href="http://nodered.org" target="_new">Node-RED</a> nodes to store, delete, restore and query objects from the
<a href="https://cloud.ibm.com/docs/services/cloud-object-storage/about-cos.html#about-ibm-cloud-object-storage" target="_new">IBM Cloud Object Storage</a> service.
This is a S3-like object storage service hosted on <a href="https://cloud.ibm.com" target="_new">IBM Cloud</a>.

## Install
-----

Run the following command in the root directory of your Node-RED install or home directory (usually ~/.node-red) and will also install necessary libraries automatically.
```sh
npm install node-red-contrib-cos
npm install @node-red-contrib-ibm-cloud/node-red-contrib-cos
```
This node was tested under Nodejs V8.x LTS and NPM 6.x on NodeRed 1.0.
This node was tested under Nodejs V16.x LTS and NPM 8.x on Node-RED 2.0.

## Usage
-----

Provides a few nodes to easily manage objects within buckets of an instantce of the IBM Object Storage Service. This node uses the S3-API to communicate with the instance.
In order to use this nodes, you must specify the credentials from the IBM Cloud Object Storage service.
Provides a set of nodes to easily manage objects within buckets of an instance of the IBM Object Storage service.
The package uses the S3-API to communicate with the IBM Cloud Object Storage service instance - this requires that you specify the credentials from the IBM Cloud Object Storage service instance.

The bucket in the IBM Cloud Object Storage service must exist. When an URL to the object is needed, use HMAC credentials within the config to provide a 15 minute accessable signed URL to the object. See <a href="https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-uhc-hmac-credentials-main" target="_new">IBM Cloud Object Storage - Using HMAC credentials</a> for more details.
Any bucket referenced by the nodes in the IBM Cloud Object Storage service instance must already exist.

When an URL to the object is requested, use HMAC credentials within the config to provide a 15 minute accessible signed URL to the object.
See <a href="https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-uhc-hmac-credentials-main" target="_new">IBM Cloud Object Storage - Using HMAC credentials</a> for more details.

### COS Object Put

Expand All @@ -31,8 +35,8 @@ Can also be used to generate a [presigned URL](https://cloud.ibm.com/docs/servic

### COS Object Del

Deletes the object from the given bucket of the IBM Cloud Object Storage Service.
Deletes the object from the given bucket of the IBM Cloud Object Storage service.

### COS Object Qry

List all of the objects of a given bucket from the IBM Cloud Object Storage Service as an array of objects.
List all of the objects of a given bucket from the IBM Cloud Object Storage service as an array of objects.
2 changes: 1 addition & 1 deletion cos.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</div>
<div id="geturlExpiry" class="form-row">
<label for="node-input-geturlExpiry"><i class="fa fa-link"></i> <span data-i18n="cos.label.geturlExpiry"></span></label>
<input type="number" value=900 min=1 max=604800 defaultValue=900 style="width: 75px" id="node-input-geturlExpiry">
<input type="text" value=900 min=1 max=604800 defaultValue=900 style="width: 75px" id="node-input-geturlExpiry">
</div>

<br/>
Expand Down
20 changes: 15 additions & 5 deletions cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = function(RED) {
var bucket;
var mode;
var geturl = node.geturl || msg.geturl;
var expiry = node.geturlExpiry;
var expiry = parseInt(node.geturlExpiry);
var config;

// Help Debug
Expand Down Expand Up @@ -480,7 +480,8 @@ module.exports = function(RED) {
cos.putObject({
Bucket: bucket,
Body: body,
Key: objectname
Key: objectname,
'Content-Type': contentType
}, function(err, data) {
if (err) {
// Send error back
Expand Down Expand Up @@ -586,7 +587,8 @@ module.exports = function(RED) {
cos.putObject({
Bucket: bucket,
Body: body,
Key: objectname
Key: objectname,
'Content-Type': contentType
}, function(err, data) {
if (err) {
// Send error back
Expand Down Expand Up @@ -645,7 +647,8 @@ module.exports = function(RED) {
cos.putObject({
Bucket: bucket,
Body: body,
Key: objectname
Key: objectname,
'Content-Type': contentType
}, function(err, data) {
if (err) {
// Send error back
Expand Down Expand Up @@ -898,6 +901,7 @@ module.exports = function(RED) {
var bucket;
var maxkeys = node.maxkeys || msg.maxkeys;
var config;
var prefix = "";

// Help Debug
console.log("Cloud Object Storage Qry (log): Init done");
Expand All @@ -918,6 +922,11 @@ module.exports = function(RED) {
} else {
objectname = node.objectname;
}

// Check prefix
if ((msg.objectprefix) && (msg.objectprefix.trim() !== "")) {
prefix = msg.objectprefix.trim();
}

// Check bucket
if ((msg.bucket) && (msg.bucket.trim() !== "")) {
Expand Down Expand Up @@ -970,7 +979,8 @@ module.exports = function(RED) {
// List of all objects
cos.listObjects({
Bucket: bucket,
MaxKeys: maxkeys
MaxKeys: maxkeys,
Prefix: prefix
// Key: objectname
}, function(err, data) {
if (err) {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "node-red-contrib-cos",
"version": "0.0.20",
"description": "Node-Red Nodes for IBM Cloud Object Storage service.",
"version": "0.1.1",
"description": "Node-RED node for IBM Cloud Object Storage",
"main": "cos.js",
"repository": {
"type": "git",
"url": "[email protected]:O-Hahn/node-red-contrib-cos"
"url": "[email protected]:node-red-contrib-ibm-cloud/node-red-contrib-cos"
},
"keywords": [
"ibm",
Expand All @@ -28,7 +28,7 @@
}
},
"bugs": {
"url": "https://github.com/O-Hahn/node-red-contrib-cos/issues"
"url": "https://github.com/node-red-contrib-ibm-cloud/node-red-contrib-cos/issues"
},
"dependencies": {
"es6-error": "latest",
Expand Down