New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

minio

Package Overview
Dependencies
Maintainers
4
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minio - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

31

dist/main/errors.js

@@ -207,3 +207,4 @@ /*

// InvalidBucketPolicyError generated when the given bucket policy is invalid.
// IncorrectSizeError generated when total data read mismatches with
// the input size.
return InvalidPrefixError;

@@ -214,21 +215,5 @@ })(_es6Error2['default']);

var InvalidBucketPolicyError = (function (_ExtendableError12) {
_inherits(InvalidBucketPolicyError, _ExtendableError12);
var IncorrectSizeError = (function (_ExtendableError12) {
_inherits(IncorrectSizeError, _ExtendableError12);
function InvalidBucketPolicyError(message) {
_classCallCheck(this, InvalidBucketPolicyError);
_get(Object.getPrototypeOf(InvalidBucketPolicyError.prototype), 'constructor', this).call(this, message);
}
// IncorrectSizeError generated when total data read mismatches with
// the input size.
return InvalidBucketPolicyError;
})(_es6Error2['default']);
exports.InvalidBucketPolicyError = InvalidBucketPolicyError;
var IncorrectSizeError = (function (_ExtendableError13) {
_inherits(IncorrectSizeError, _ExtendableError13);
function IncorrectSizeError(message) {

@@ -246,4 +231,4 @@ _classCallCheck(this, IncorrectSizeError);

var InvalidXMLError = (function (_ExtendableError14) {
_inherits(InvalidXMLError, _ExtendableError14);
var InvalidXMLError = (function (_ExtendableError13) {
_inherits(InvalidXMLError, _ExtendableError13);

@@ -263,4 +248,4 @@ function InvalidXMLError(message) {

var S3Error = (function (_ExtendableError15) {
_inherits(S3Error, _ExtendableError15);
var S3Error = (function (_ExtendableError14) {
_inherits(S3Error, _ExtendableError14);

@@ -267,0 +252,0 @@ function S3Error(message) {

@@ -54,25 +54,6 @@ /*

// All characters in string which are NOT unreserved should be percent encoded.
// Unreserved characers are : ALPHA / DIGIT / "-" / "." / "_" / "~"
// Reference https://tools.ietf.org/html/rfc3986#section-2.2
function uriEscape(string) {
return string.split('').reduce(function (acc, elem) {
var buf = new Buffer(elem);
if (buf.length === 1) {
// length 1 indicates that elem is not a unicode character.
// Check if it is an unreserved characer.
if ('A' <= elem && elem <= 'Z' || 'a' <= elem && elem <= 'z' || '0' <= elem && elem <= '9' || elem === '_' || elem === '.' || elem === '~' || elem === '-') {
// Unreserved characer should not be encoded.
acc = acc + elem;
return acc;
}
}
// elem needs encoding - i.e elem should be encoded if it's not unreserved
// character or if it's a unicode character.
for (var i = 0; i < buf.length; i++) {
acc = acc + "%" + buf[i].toString(16).toUpperCase();
}
return acc;
}, '');
return encodeURIComponent(string).replace(/[*]/g, function (ch) {
return '%' + ch.charCodeAt(0).toString(16).toUpperCase();
});
}

@@ -260,3 +241,3 @@

// pipesetup will also make sure that error emitted at any of the upstream Stream
// will be emitted at the last stream. This makes error handling simple
// will be emited at the last stream. This makes error handling simple

@@ -263,0 +244,0 @@ function pipesetup() {

@@ -34,3 +34,2 @@ /*

'eu-central-1': 's3-eu-central-1.amazonaws.com',
'ap-south-1': 's3-ap-south-1.amazonaws.com',
'ap-southeast-1': 's3-ap-southeast-1.amazonaws.com',

@@ -37,0 +36,0 @@ 'ap-southeast-2': 's3-ap-southeast-2.amazonaws.com',

@@ -31,8 +31,4 @@ /*

exports.getListObjectsTransformer = getListObjectsTransformer;
exports.getListObjectsV2Transformer = getListObjectsV2Transformer;
exports.getCompleteMultipartTransformer = getCompleteMultipartTransformer;
exports.getBucketRegionTransformer = getBucketRegionTransformer;
exports.getBucketNotificationTransformer = getBucketNotificationTransformer;
exports.getNotificationTransformer = getNotificationTransformer;
exports.getBucketPolicyTransformer = getBucketPolicyTransformer;

@@ -47,4 +43,2 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _bucketPolicyJs = require('./bucket-policy.js');
var _lodash = require('lodash');

@@ -62,6 +56,2 @@

var _jsonStream = require('json-stream');
var _jsonStream2 = _interopRequireDefault(_jsonStream);
var _helpersJs = require('./helpers.js');

@@ -244,8 +234,2 @@

// Parses listObjects response.
function getListObjectsV2Transformer() {
return getConcater(xmlParsers.parseListObjectsV2);
}
// Parses completeMultipartUpload response.

@@ -262,23 +246,2 @@

}
// Parses GET/SET BucketNotification response
function getBucketNotificationTransformer() {
return getConcater(xmlParsers.parseBucketNotification);
}
// Parses a notification.
function getNotificationTransformer() {
// This will parse and return each object.
return new _jsonStream2['default']();
}
// Parses GET BucketPolicy response.
function getBucketPolicyTransformer() {
return getConcater(function (response) {
return JSON.parse(response);
});
}
//# sourceMappingURL=transformers.js.map

@@ -25,3 +25,2 @@ /*

exports.parseListBucket = parseListBucket;
exports.parseBucketNotification = parseBucketNotification;
exports.parseBucketRegion = parseBucketRegion;

@@ -32,3 +31,2 @@ exports.parseListParts = parseListParts;

exports.parseListObjects = parseListObjects;
exports.parseListObjectsV2 = parseListObjectsV2;

@@ -147,69 +145,2 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }

// parse XML response for bucket notification
function parseBucketNotification(xml) {
var result = {
TopicConfiguration: [],
QueueConfiguration: [],
CloudFunctionConfiguration: []
};
// Parse the events list
var genEvents = function genEvents(events) {
var result = [];
if (events) {
events.forEach(function (s3event) {
result.push(s3event);
});
}
return result;
};
// Parse all filter rules
var genFilterRules = function genFilterRules(filters) {
var result = [];
if (filters && filters[0].S3Key && filters[0].S3Key[0].FilterRule) {
filters[0].S3Key[0].FilterRule.forEach(function (rule) {
var Name = rule.Name[0];
var Value = rule.Value[0];
result.push({ Name: Name, Value: Value });
});
}
return result;
};
var xmlobj = parseXml(xml);
// Parse all topic configurations in the xml
if (xmlobj.TopicConfiguration) {
xmlobj.TopicConfiguration.forEach(function (config) {
var Id = config.Id[0];
var Topic = config.Topic[0];
var Event = genEvents(config.Event);
var Filter = genFilterRules(config.Filter);
result.TopicConfiguration.push({ Id: Id, Topic: Topic, Event: Event, Filter: Filter });
});
}
// Parse all topic configurations in the xml
if (xmlobj.QueueConfiguration) {
xmlobj.QueueConfiguration.forEach(function (config) {
var Id = config.Id[0];
var Queue = config.Queue[0];
var Event = genEvents(config.Event);
var Filter = genFilterRules(config.Filter);
result.QueueConfiguration.push({ Id: Id, Queue: Queue, Event: Event, Filter: Filter });
});
}
// Parse all QueueConfiguration arrays
if (xmlobj.CloudFunctionConfiguration) {
xmlobj.CloudFunctionConfiguration.forEach(function (config) {
var Id = config.Id[0];
var CloudFunction = config.CloudFunction[0];
var Event = genEvents(config.Event);
var Filter = genFilterRules(config.Filter);
result.CloudFunctionConfiguration.push({ Id: Id, CloudFunction: CloudFunction, Event: Event, Filter: Filter });
});
}
return result;
}
// parse XML response for bucket region

@@ -255,16 +186,8 @@

var xmlobj = parseXml(xml);
if (xmlobj.Location) {
var location = xmlobj.Location[0];
var bucket = xmlobj.Bucket[0];
var key = xmlobj.Key[0];
var etag = xmlobj.ETag[0].replace(/^\"/g, '').replace(/\"$/g, '').replace(/^&quot;/g, '').replace(/&quot;$/g, '').replace(/^&#34;/g, '').replace(/^&#34;$/g, '');
var location = xmlobj.Location[0];
var bucket = xmlobj.Bucket[0];
var key = xmlobj.Key[0];
var etag = xmlobj.ETag[0].replace(/^\"/g, '').replace(/\"$/g, '').replace(/^&quot;/g, '').replace(/&quot;$/g, '').replace(/^&#34;/g, '').replace(/^&#34;$/g, '');
return { location: location, bucket: bucket, key: key, etag: etag };
}
// Complete Multipart can return XML Error after a 200 OK response
if (xmlobj.Code && xmlobj.Message) {
var errCode = xmlobj.Code[0];
var errMessage = xmlobj.Message[0];
return { errCode: errCode, errMessage: errMessage };
}
return { location: location, bucket: bucket, key: key, etag: etag };
}

@@ -304,33 +227,2 @@

}
// parse XML response for list objects v2 in a bucket
function parseListObjectsV2(xml) {
var result = {
objects: [],
isTruncated: false
};
var nextMarker;
var xmlobj = parseXml(xml);
if (xmlobj.IsTruncated && xmlobj.IsTruncated[0] === 'true') result.isTruncated = true;
if (xmlobj.NextContinuationToken) result.nextContinuationToken = xmlobj.NextContinuationToken[0];
if (xmlobj.Contents) {
xmlobj.Contents.forEach(function (content) {
var name = content.Key[0];
var lastModified = new Date(content.LastModified[0]);
var etag = content.ETag[0].replace(/^\"/g, '').replace(/\"$/g, '').replace(/^&quot;/g, '').replace(/&quot;$/g, '').replace(/^&#34;/g, '').replace(/^&#34;$/g, '');
var size = +content.Size[0];
result.objects.push({ name: name, lastModified: lastModified, etag: etag, size: size });
});
}
if (xmlobj.CommonPrefixes) {
xmlobj.CommonPrefixes.forEach(function (commonPrefix) {
var prefix = commonPrefix.Prefix[0];
var size = 0;
result.objects.push({ prefix: prefix, size: size });
});
}
return result;
}
//# sourceMappingURL=xml-parsers.js.map

@@ -35,11 +35,10 @@ # JavaScript Client API Reference [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

| Bucket operations | Object operations | Presigned operations | Bucket Policy & Notification operations |
| ------------- |-------------| -----| ----- |
| [`makeBucket`](#makeBucket) | [`getObject`](#getObject) | [`presignedGetObject`](#presignedGetObject) | [`getBucketNotification`](#getBucketNotification) |
| [`listBuckets`](#listBuckets) | [`getPartialObject`](#getPartialObject) | [`presignedPutObject`](#presignedPutObject) | [`setBucketNotification`](#setBucketNotification) |
| [`bucketExists`](#bucketExists) | [`fGetObject`](#fGetObject) | [`presignedPostPolicy`](#presignedPostPolicy) | [`removeAllBucketNotification`](#removeAllBucketNotification) |
| [`removeBucket`](#removeBucket) | [`putObject`](#putObject) | | [`getBucketPolicy`](#getBucketPolicy) | [`listenBucketNotification`](#listenBucketNotification) |
| [`listObjects`](#listObjects) | [`fPutObject`](#fPutObject) | | [`setBucketPolicy`](#setBucketPolicy)
| [`listObjectsV2`](#listObjectsV2) | [`statObject`](#statObject) |
| [`listIncompleteUploads`](#listIncompleteUploads) | |
| Bucket operations | Object operations | Presigned operations |
| ------------- |-------------| -----|
| [`makeBucket`](#makeBucket) | [`getObject`](#getObject) | [`presignedGetObject`](#presignedGetObject) |
| [`listBuckets`](#listBuckets) | [`getPartialObject`](#getPartialObject) | [`presignedPutObject`](#presignedPutObject) |
| [`bucketExists`](#bucketExists) | [`fGetObject`](#fGetObject) | [`presignedPostPolicy`](#presignedPostPolicy) |
| [`removeBucket`](#removeBucket) | [`putObject`](#putObject) |
| [`listObjects`](#listObjects) | [`fPutObject`](#fPutObject) |
| [`listIncompleteUploads`](#listIncompleteUploads) |[`statObject`](#statObject) |
| | [`removeObject`](#removeObject) |

@@ -61,14 +60,64 @@ | | [`removeIncompleteUpload`](#removeIncompleteUpload) |

| Param | Type | Description |
|---|---|---|
| `endPoint` | _string_ | endPoint is an URL, domain name, IPv4 address or IPv6 address.Valid endpoints are listed below: |
| | |https://s3.amazonaws.com |
| | |https://play.minio.io:9000 |
| | |localhost |
| | |play.minio.io|
| `port` | _number_ | TCP/IP port number. This input is optional. Default value set to 80 for HTTP and 443 for HTTPs. |
| `accessKey` | _string_ |accessKey is like user-id that uniquely identifies your account. |
|`secretKey` | _string_ | secretKey is the password to your account.|
|`secure` | _bool_ |If set to true, https is used instead of http. Default is https if not set. |
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code> endPoint <code>
</td>
<td>
<i> string </i>
</td>
<td>
endPoint is an URL, domain name, IPv4 or IPv6 address.
<br/>Valid endpoints:
<ul>
<li>https://s3.amazonaws.com</li>
<li>https://s3.amazonaws.com/</li>
<li>https://play.minio.io:9000</li>
<li>http://play.minio.io:9010/</li>
<li>localhost</li>
<li>localhost.localdomain</li>
<li>play.minio.io</li>
<li>127.0.0.1</li>
<li>192.168.1.60</li>
<li>::1</li>
</ul>
</td>
</tr>
<tr>
<td>
<code> port </code>
</td>
<td>
<i> number </i>
</td>
<td>
TCP/IP port number. This input is optional. Default value set to 80 for HTTP and 443 for HTTPs.
</td>
</tr>
<tr>
<td> <code> accessKey </code> </td>
<td> <i> string </i> </td>
<td>accessKey is like user-id that uniquely identifies your account.</td>
</tr>
<tr>
<td> <code> secretKey </code> </td>
<td> <i> string </i> </td>
<td> secretKey is the password to your account.</td>
</tr>
<tr>
<td> <code> secure </code> </td>
<td> <i> bool </i> </td>
<td>If set to true, https is used instead of http. Default is https if not set. </td>
</tr>
</tbody>
</table>

@@ -121,17 +170,43 @@

| Param | Type | Description |
|---|---|---|
|`bucketName` | _string_ | Name of the bucket. |
| `region` | _string_ | Default value is us-east-1 Region where the bucket is created. Valid values are listed below: |
| | |us-east-1 |
| | |us-west-1 |
| | |us-west-2 |
| | |eu-west-1 |
| | | eu-central-1|
| | | ap-southeast-1|
| | | ap-northeast-1|
| | | ap-southeast-2|
| | | sa-east-1|
|`callback(err)` |_function_ | Callback function with `err` as the error argument. `err` is null if the bucket is successfully created. |
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code> bucketName </code>
</td>
<td>
<i> string </i>
</td>
<td>
Name of the bucket.
</td>
</tr>
<tr>
<td>
<code> region </code>
</td>
<td>
<i> string </i>
</td>
<td>
Default value is us-east-1
Region where the bucket is created. Valid values are [ <i> us-east-1, us-west-1, us-west-2, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1,
ap-southeast-2, sa-east-1 </i> ].
</td>
</tr>
<tr>
<td> <code> callback(err) </code> </td>
<td> <i> function </i> </td>
<td>Callback function with <code>err</code> as the error argument. <code>err</code> is null if the bucket is successfully created. </td>
</tr>
</tbody>
</table>

@@ -161,15 +236,34 @@

| Param | Type | Description |
|---|---|---|
|`callback(err, bucketStream) ` | _function_ | Callback function with error as the first argument. bucketStream is the stream emitting bucket information. |
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code> callback(err, bucketStream) </code>
</td>
<td>
<i> function </i>
</td>
<td>
Callback function with error as the first argument.
<code>bucketStream</code> is the stream emitting bucket information.
<br/><code>bucketStream</code> emits Object with the format:-
<ul>
<li> <code>bucket.name</code> <i>string</i> : bucket name</li>
<li> <code>bucket.creationDate</code> <i>Date</i> : date when bucket was created.</li>
bucketStream emits Object with the format:-
</ul>
</td>
</tr>
| Param | Type | Description |
|---|---|---|
|`bucket.name` | _string_ |bucket name |
|`bucket.creationDate`| _Date_ |date when bucket was created. |
</tbody>
</table>
__Example__

@@ -217,3 +311,2 @@

```
<a name="removeBucket"></a>

@@ -263,15 +356,34 @@ ### removeBucket(bucketName, callback)

| Param | Type | Description |
| ---- | ---- | ---- |
| `stream` | _Stream_ | Stream emitting the objects in the bucket. |
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code> stream </code>
</td>
<td>
<i> Stream </i>
</td>
<td>
Stream emitting the objects in the bucket, the object is of the format:
<ul>
<li> <code>obj.key</code> <i>string</i>: name of the object.</li>
<li> <code>obj.size</code> <i>number</i>: size of the object.</li>
<li> <code>obj.etag</code> <i>string</i>: etag of the object.</li>
<li> <code>obj.lastModified</code> <i>Date</i>: modified time stamp.</li>
</ul>
</td>
</tr>
The object is of the format:
</tbody>
</table>
| Param | Type | Description |
| ---- | ---- | ---- |
| `obj.key` | _string_ | name of the object. |
| `obj.size` | _number_ | size of the object. |
| `obj.etag` | _string_ |etag of the object. |
| `obj.lastModified` | _Date_ | modified time stamp. |
__Example__

@@ -288,45 +400,2 @@

<a name="listObjectsV2"></a>
### listObjectsV2(bucketName, prefix, recursive)
Lists all objects in a bucket using S3 listing objects V2 API
__Parameters__
| Param | Type | Description |
| ---- | ---- | ---- |
| `bucketName` | _string_ | Name of the bucket. |
| `prefix` | _string_ | The prefix of the objects that should be listed (optional, default `''`). |
| `recursive` | _bool_ | `true` indicates recursive style listing and `false` indicates directory style listing delimited by '/'. (optional, default `false`). |
__Return Value__
| Param | Type | Description |
| ---- | ---- | ---- |
| `stream` | _Stream_ | Stream emitting the objects in the bucket. |
The object is of the format:
| Param | Type | Description |
| ---- | ---- | ---- |
| `obj.key` | _string_ | name of the object. |
| `obj.size` | _number_ | size of the object. |
| `obj.etag` | _string_ |etag of the object. |
| `obj.lastModified` | _Date_ | modified time stamp. |
__Example__
```js
var stream = minioClient.listObjectsV2('mybucket','', true)
stream.on('data', function(obj) { console.log(obj) } )
stream.on('error', function(err) { console.log(err) } )
```
<a name="listIncompleteUploads"></a>

@@ -350,12 +419,33 @@ ### listIncompleteUploads(bucketName, prefix, recursive)

| Param | Type | Description |
| ---| ---|---|
| `stream` | _Stream_ | Emits objects of the format listed below:|
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code> stream </code>
</td>
<td>
<i> Stream </i>
</td>
<td>
Emits objects of the format:
| Param | Type | Description |
| ---| ---|---|
| `part.key` | _string_ | name of the object.|
| `part.uploadId` | _string_ | upload ID of the object.|
| `part.size` | _Integer_ | size of the partially uploaded object.|
<ul>
<li> <code>part.key</code> <i>string</i>: name of the object.</li>
<li> <code>part.uploadId</code> <i>string</i>: upload ID of the object.</li>
<li> <code>part.size</code> <i>Integer</i>: size of the partially uploaded object.</li>
</ul>
</td>
</tr>
</tbody>
</table>
__Example__

@@ -464,2 +554,4 @@

| Param | Type | Description |

@@ -507,3 +599,2 @@ |---|---|---|

__Example__

@@ -592,18 +683,49 @@

| Param | Type | Description |
|---|---|---|
| `bucketName` | _string_ | Name of the bucket. |
| `objectName` | _string_ | Name of the object. |
| `callback(err, stat)` | _function_ |`err` is not `null` in case of error, `stat` contains the object information listed below: |
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code> bucketName </code>
</td>
<td>
<i> string </i>
</td>
<td>
Name of the bucket.
</td>
</tr>
<tr>
<td> <code> objectName </code> </td>
<td> <i> string </i> </td>
<td>Name of the object.</td>
</tr>
<tr>
<td>
<code> callback(err, stat) </code>
</td>
<td>
<i> function </i>
</td>
<td>
<code>err</code> is not <code>null</code> in case of error, <code>stat</code> contains the object information:
<ul>
<li> <code>stat.size</code> <i>number</i>: size of the object.</li>
<li> <code>stat.etag</code> <i>string</i>: etag of the object.</li>
<li> <code>stat.contentType</code> <i>string</i>: Content-Type of the object.</li>
<li> <code>stat.lastModified</code> <i>string</i>: modified time stamp.</li>
</ul>
</td>
</td>
</tr>
</tbody>
</table>
| Param | Type | Description |
|---|---|---|
| `stat.size` | _number_ | size of the object. |
| `stat.etag` | _string_ | etag of the object. |
| `stat.contentType` | _string_ | Content-Type of the object.|
| `stat.lastModified` | _string_ | Last Modified time stamp.|
__Example__

@@ -826,191 +948,5 @@

## 5. Bucket Policy & Notification operations
## 5. Explore Further
Buckets are configured to trigger notifications on specified types of events and paths filters.
<a name="getBucketNotification"></a>
### getBucketNotification(bucketName, cb)
Fetch the notification configuration stored in the S3 provider and that belongs to the specified bucket name.
__Parameters__
| Param | Type | Description |
|---|---|---|
| `bucketName` | _string_ | Name of the bucket. |
| `callback(err, bucketNotificationConfig)` | _function_ | Callback function is called with non `null` err value in case of error. `bucketNotificationConfig` will be the object that carries all notification configurations associated to bucketName. |
__Example__
```js
minioClient.getBucketNotification('mybucket', function(err, bucketNotificationConfig) {
if (err) return console.log(err)
console.log(bucketNotificationConfig)
})
```
<a name="setBucketNotification"></a>
### setBucketNotification(bucketName, bucketNotificationConfig, callback)
Upload a user-created notification configuration and associate it to the specified bucket name.
__Parameters__
| Param | Type | Description |
|---|---|---|
| `bucketName` | _string_ | Name of the bucket. |
| `bucketNotificationConfig` | _BucketNotification_ | Javascript object that carries the notification configuration. |
| `callback(err)` | _function_ | Callback function is called with non `null` err value in case of error. |
__Example__
```js
// Create a new notification object
var bucketNotification = new Notify.BucketNotification();
// Setup a new topic configuration
var arn = Notify.newARN('aws', 'sns', 'us-west-2', '408065449417', 'TestTopic')
var topic = new Notify.TopicConfig(arn)
topic.addFilterSuffix('.jpg')
topic.addFilterPrefix('myphotos/')
topic.addEvent(Notify.ObjectReducedRedundancyLostObject)
topic.addEvent(Notify.ObjectCreatedAll)
// Add the topic to the overall notification object
bucketNotification.addTopicConfiguration(topic)
minioClient.setBucketNotification('mybucket', bucketNotification, function(err) {
if (err) return console.log(err)
console.log('Success')
})
```
<a name="removeAllBucketNotification"></a>
### removeAllBucketNotification(bucketName, callback)
Remove the bucket notification configuration associated to the specified bucket.
__Parameters__
| Param | Type | Description |
|---|---|---|
| `bucketName` | _string_ | Name of the bucket |
| `callback(err)` | _function_ | Callback function is called with non `null` err value in case of error. |
```js
minioClient.removeAllBucketNotification('my-bucketname', function(e) {
if (e) {
return console.log(e)
}
console.log("True")
})
```
<a name="listenBucketNotification"></a>
### listenBucketNotification(bucketName, notificationARN)
Listen for notifications on a bucket, using the given notification ARN. The bucket
must already have a notification configuration set.
Returns an `EventEmitter`, which will emit a `notification` event carrying the record.
To stop listening, call `.stop()` on the returned `EventEmitter`.
__Parameters__
| Param | Type | Description |
|---|---|---|
| `bucketName` | _string_ | Name of the bucket |
| `notificationARN` | _string_ | Amazon Resource Name, built using `Minio.buildARN`. |
See [here](../examples/minio/listen-bucket-notification.js) for a full example.
```js
// 'us-east-1' may have to be replaced with your bucket region (use `getBucketRegion`).
// '123' is an account ID, which need not be changed.
var arn = Minio.buildARN('minio', 'sns', 'us-east-1', '123', 'listen')
var listener = minioClient.listenBucketNotification('my-bucketname', arn)
listener.on('notification', function(record) {
// For example: 's3:ObjectCreated:Put event occurred (2016-08-23T18:26:07.214Z)'
console.log('%s event occurred (%s)', record.eventName, record.eventTime)
listener.stop()
})
```
<a name="getBucketPolicy"></a>
### getBucketPolicy(bucketName, objectPrefix, callback)
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__
| Param | Type | Description |
|---|---|---|
| `bucketName` | _string_ | Name of the bucket |
| `objectPrefix` | _string_ | Prefix of objects in the bucket with which to filter permissions off of. Use `''` for entire bucket. |
| `callback(err, policy)` | _function_ | Callback function is called with non `null` err value in case of error. `policy` will be the string representation of the bucket policy (`minio.Policy.NONE`, `minio.Policy.READONLY`, `minio.Policy.WRITEONLY`, or `minio.Policy.READWRITE`). |
```js
// Retrieve bucket policy of 'my-bucketname' that applies to all objects that
// start with 'img-'.
minioClient.getBucketPolicy('my-bucketname', 'img-', function(err, policy) {
if (err) throw err
console.log(`Bucket policy: ${policy}`)
})
```
<a name="setBucketPolicy"></a>
### setBucketPolicy(bucketName, objectPrefix, bucketPolicy, callback)
Set the bucket policy associated with the specified bucket. If `objectPrefix`
is not empty, the bucket policy will only be assigned to objects that fit the
given prefix.
__Parameters__
| Param | Type | Description |
|---|---|---|
| `bucketName` | _string_ | Name of the bucket |
| `objectPrefix` | _string_ | Prefix of objects in the bucket to modify permissions of. Use `''` for entire bucket. |
| `bucketPolicy` | _string_ | The bucket policy. This can be: `minio.Policy.NONE`, `minio.Policy.READONLY`, `minio.Policy.WRITEONLY`, or `minio.Policy.READWRITE`. |
| `callback(err)` | _function_ | Callback function is called with non `null` err value in case of error. |
```js
// Set the bucket policy of `my-bucketname` to `readonly` (only allow retrieval),
// but only for objects that start with 'img-'.
minioClient.setBucketPolicy('my-bucketname', 'img-', minio.Policy.READONLY, function(err) {
if (err) throw err
console.log('Set bucket policy to \'readonly\'.')
})
```
## 6. Explore Further
- [Build your own Shopping App Example](https://docs.minio.io/docs/javascript-shopping-app)

@@ -23,3 +23,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -26,0 +26,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -22,3 +22,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -25,0 +25,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -23,3 +23,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -26,0 +26,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -22,3 +22,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -25,0 +25,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -23,3 +23,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -26,0 +26,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -22,3 +22,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -25,0 +25,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -22,3 +22,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -25,0 +25,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -22,3 +22,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -25,0 +25,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -22,3 +22,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -25,0 +25,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -22,3 +22,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -25,0 +25,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -22,3 +22,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -25,0 +25,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -22,3 +22,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -25,0 +25,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -23,3 +23,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -26,0 +26,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -22,3 +22,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -25,0 +25,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -23,3 +23,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -26,0 +26,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -23,3 +23,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -26,0 +26,0 @@ accessKey: 'YOUR-ACCESSKEYID',

@@ -23,3 +23,3 @@ /*

var s3Client = new Minio.Client({
var s3Client = new Minio({
endPoint: 's3.amazonaws.com',

@@ -26,0 +26,0 @@ accessKey: 'YOUR-ACCESSKEYID',

{
"name": "minio",
"version": "2.0.2",
"version": "2.0.3",
"description": "S3 Compatible Cloud Storage client",

@@ -34,4 +34,3 @@ "main": "./dist/main/minio.js",

"es6-error": "^2.0.2",
"json-stream": "^1.0.0",
"lodash": "^4.14.2",
"lodash": "^3.10.1",
"mkdirp": "^0.5.1",

@@ -38,0 +37,0 @@ "moment": "^2.10.3",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc