From 83d8dd0f50a2a6811547cd024ce4f549826db32b Mon Sep 17 00:00:00 2001 From: prakashsvmx Date: Fri, 4 Jun 2021 09:19:29 +0530 Subject: [PATCH] Address review comments by Ersan --- docs/API.md | 12 ++++++------ examples/get-object-legal-hold.js | 18 +++++++++++++++--- examples/set-object-legal-hold.js | 4 ++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/docs/API.md b/docs/API.md index 20f308a4..4b1d6805 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1607,27 +1607,27 @@ __Parameters__ | `callback(err)` | _function_ |Callback function is called with non `null` value in case of error. If no callback is passed, a `Promise` is returned. | -__Example__ +__Example 1__ Get Legal hold of an object. ```js minioClient.getObjectLegalHold('bucketName', 'objectName', {}, function(err, res) { if (err) { - return console.log('Unable to get legal hold config for the object', err) + return console.log('Unable to get legal hold config for the object', err.message) } console.log('Success', res) }) ``` -__Example 1__ +__Example 2__ Get Legal hold of an object with versionId. ```js minioClient.getObjectLegalHold('bucketName', 'objectName', { versionId:'my-obj-version-uuid' }, function(err, res) { if (err) { - return console.log('Unable to get legal hold config for the object', err) + return console.log('Unable to get legal hold config for the object', err.message) } console.log('Success', res) }) @@ -1656,7 +1656,7 @@ Set Legal hold of an object. ```js minioClient.setObjectLegalHold('bucketName', 'objectName', {Status:"ON"}, function(err, res) { if (err) { - return console.log('Unable to set legal hold config for the object', err) + return console.log('Unable to set legal hold config for the object', err.message) } console.log('Success') }) @@ -1668,7 +1668,7 @@ Set Legal hold of an object with versionId. ```js minioClient.setObjectLegalHold('bucketName', 'objectName', { Status:"ON", versionId:'my-obj-version-uuid' }, function(err, res) { if (err) { - return console.log('Unable to set legal hold config for the object version', err) + return console.log('Unable to set legal hold config for the object version', err.message) } console.log('Success') }) diff --git a/examples/get-object-legal-hold.js b/examples/get-object-legal-hold.js index 2c0de23d..1e42a14b 100644 --- a/examples/get-object-legal-hold.js +++ b/examples/get-object-legal-hold.js @@ -28,7 +28,7 @@ var s3Client = new Minio.Client({ //Get Legalhold config s3Client.getObjectLegalHold('bucketName', 'objectName', {}, function(err, res) { if (err) { - return console.log('Unable to get legal hold config for the object', err) + return console.log('Unable to get legal hold config for the object', err.message) // Print only the message. } console.log(res) }) @@ -36,7 +36,19 @@ s3Client.getObjectLegalHold('bucketName', 'objectName', {}, function(err, res) { //With versionId s3Client.getObjectLegalHold('bucketName', 'objectName', { versionId:'my-obj-version-uuid' }, function(err, res) { if (err) { - return console.log('Unable to get legal hold config for the object', err) + return console.log('Unable to get legal hold config for the object', err.message) // Print only the message. } console.log(res) -}) \ No newline at end of file +}) + +//Promise based version: +const objectLegalHoldPromise = s3Client.getObjectLegalHold('bucketName', 'objectName', { versionId:'my-obj-version-uuid' }) +objectLegalHoldPromise.then((data) => { + console.log("Success...", data) +}) + .catch((e)=>{ + // Print only the error message. if called on an object without object lock config. + // e.g: "The specified object does not have a ObjectLock configuration" + console.log(e.message) + + }) diff --git a/examples/set-object-legal-hold.js b/examples/set-object-legal-hold.js index 7ec1c1be..0320639c 100644 --- a/examples/set-object-legal-hold.js +++ b/examples/set-object-legal-hold.js @@ -30,7 +30,7 @@ s3Client.setObjectLegalHold('bucketName', 'objectName', {status:"ON"}, function( if (err) { return console.log('Unable to set legal hold config for the object', err) } - console.log('Success', res) + console.log('Success') }) //Set legal hold config of an object with versionId. @@ -38,5 +38,5 @@ s3Client.setObjectLegalHold('bucketName', 'objectName', { status:"ON", versionId if (err) { return console.log('Unable to set legal hold config for the object version', err) } - console.log('Success', res) + console.log('Success') }) \ No newline at end of file