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
2 changes: 1 addition & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
spec: 'tests/**/*.js',
spec: 'tests/**/*.{js,ts}',
exit: true,
reporter: 'spec',
ui: 'bdd',
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ The complete API Reference is available here:
#### Bucket Operations

- [list-buckets.mjs](https://github.com/minio/minio-js/blob/master/examples/list-buckets.mjs)
- [list-objects.js](https://github.com/minio/minio-js/blob/master/examples/list-objects.js)
- [list-objects-v2.js](https://github.com/minio/minio-js/blob/master/examples/list-objects-v2.js)
- [list-objects-v2-with-metadata.js](https://github.com/minio/minio-js/blob/master/examples/list-objects-v2-with-metadata.js) (Extension)
- [list-objects.mjs](https://github.com/minio/minio-js/blob/master/examples/list-objects.mjs)
- [list-objects-v2.mjs](https://github.com/minio/minio-js/blob/master/examples/list-objects-v2.mjs)
- [list-objects-v2-with-metadata.mjs](https://github.com/minio/minio-js/blob/master/examples/list-objects-v2-with-metadata.mjs) (Extension)
- [bucket-exists.mjs](https://github.com/minio/minio-js/blob/master/examples/bucket-exists.mjs)
- [make-bucket.mjs](https://github.com/minio/minio-js/blob/master/examples/make-bucket.mjs)
- [remove-bucket.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-bucket.mjs)
- [list-incomplete-uploads.js](https://github.com/minio/minio-js/blob/master/examples/list-incomplete-uploads.js)
- [list-incomplete-uploads.mjs](https://github.com/minio/minio-js/blob/master/examples/list-incomplete-uploads.mjs)
- [get-bucket-versioning.mjs](https://github.com/minio/minio-js/blob/master/examples/get-bucket-versioning.mjs)
- [set-bucket-versioning.mjs](https://github.com/minio/minio-js/blob/master/examples/set-bucket-versioning.mjs)
- [set-bucket-tagging.mjs](https://github.com/minio/minio-js/blob/master/examples/set-bucket-tagging.mjs)
Expand Down Expand Up @@ -225,8 +225,8 @@ The complete API Reference is available here:
- [get-object.mjs](https://github.com/minio/minio-js/blob/master/examples/get-object.mjs)
- [copy-object.mjs](https://github.com/minio/minio-js/blob/master/examples/copy-object.mjs)
- [get-partialobject.mjs](https://github.com/minio/minio-js/blob/master/examples/get-partialobject.mjs)
- [remove-object.js](https://github.com/minio/minio-js/blob/master/examples/remove-object.js)
- [remove-incomplete-upload.js](https://github.com/minio/minio-js/blob/master/examples/remove-incomplete-upload.js)
- [remove-object.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-object.mjs)
- [remove-incomplete-upload.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-incomplete-upload.mjs)
- [stat-object.mjs](https://github.com/minio/minio-js/blob/master/examples/stat-object.mjs)
- [get-object-retention.mjs](https://github.com/minio/minio-js/blob/master/examples/get-object-retention.mjs)
- [put-object-retention.mjs](https://github.com/minio/minio-js/blob/master/examples/put-object-retention.mjs)
Expand All @@ -246,19 +246,19 @@ The complete API Reference is available here:

#### Bucket Notification Operations

- [get-bucket-notification.js](https://github.com/minio/minio-js/blob/master/examples/get-bucket-notification.js)
- [set-bucket-notification.js](https://github.com/minio/minio-js/blob/master/examples/set-bucket-notification.js)
- [remove-all-bucket-notification.js](https://github.com/minio/minio-js/blob/master/examples/remove-all-bucket-notification.js)
- [listen-bucket-notification.js](https://github.com/minio/minio-js/blob/master/examples/minio/listen-bucket-notification.js) (MinIO Extension)
- [get-bucket-notification.mjs](https://github.com/minio/minio-js/blob/master/examples/get-bucket-notification.mjs)
- [set-bucket-notification.mjs](https://github.com/minio/minio-js/blob/master/examples/set-bucket-notification.mjs)
- [remove-all-bucket-notification.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-all-bucket-notification.mjs)
- [listen-bucket-notification.mjs](https://github.com/minio/minio-js/blob/master/examples/minio/listen-bucket-notification.mjs) (MinIO Extension)

#### Bucket Policy Operations

- [get-bucket-policy.js](https://github.com/minio/minio-js/blob/master/examples/get-bucket-policy.js)
- [get-bucket-policy.mjs](https://github.com/minio/minio-js/blob/master/examples/get-bucket-policy.mjs)
- [set-bucket-policy.mjs](https://github.com/minio/minio-js/blob/master/examples/set-bucket-policy.mjs)

## Custom Settings

- [setAccelerateEndPoint](https://github.com/minio/minio-js/blob/master/examples/set-accelerate-end-point.js)
- [setAccelerateEndPoint](https://github.com/minio/minio-js/blob/master/examples/set-accelerate-end-point.mjs)

## Explore Further

Expand Down
36 changes: 18 additions & 18 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,40 +151,40 @@ mc ls play/europetrip/

#### 完整示例 : 操作存储桶

* [list-buckets.js](https://github.com/minio/minio-js/blob/master/examples/list-buckets.js)
* [list-objects.js](https://github.com/minio/minio-js/blob/master/examples/list-objects.js)
* [list-objects-v2.js](https://github.com/minio/minio-js/blob/master/examples/list-objects-v2.js)
* [list-buckets.mjs](https://github.com/minio/minio-js/blob/master/examples/list-buckets.mjs)
* [list-objects.mjs](https://github.com/minio/minio-js/blob/master/examples/list-objects.mjs)
* [list-objects-v2.mjs](https://github.com/minio/minio-js/blob/master/examples/list-objects-v2.mjs)
* [bucket-exists.mjs](https://github.com/minio/minio-js/blob/master/examples/bucket-exists.mjs)
* [make-bucket.mjs](https://github.com/minio/minio-js/blob/master/examples/make-bucket.js)
* [make-bucket.mjs](https://github.com/minio/minio-js/blob/master/examples/make-bucket.mjs)
* [remove-bucket.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-bucket.mjs)
* [list-incomplete-uploads.js](https://github.com/minio/minio-js/blob/master/examples/list-incomplete-uploads.js)
* [list-incomplete-uploads.mjs](https://github.com/minio/minio-js/blob/master/examples/list-incomplete-uploads.mjs)

#### 完整示例 : 操作文件对象
* [fput-object.mjs](https://github.com/minio/minio-js/blob/master/examples/fput-object.js)
* [fput-object.mjs](https://github.com/minio/minio-js/blob/master/examples/fput-object.mjs)
* [fget-object.mjs](https://github.com/minio/minio-js/blob/master/examples/fget-object.mjs)

#### 完整示例 : 操作对象
* [put-object.js](https://github.com/minio/minio-js/blob/master/examples/put-object.js)
* [put-object.mjs](https://github.com/minio/minio-js/blob/master/examples/put-object.mjs)
* [get-object.mjs](https://github.com/minio/minio-js/blob/master/examples/get-object.mjs)
* [copy-object.js](https://github.com/minio/minio-js/blob/master/examples/copy-object.js)
* [copy-object.mjs](https://github.com/minio/minio-js/blob/master/examples/copy-object.mjs)
* [get-partialobject.mjs](https://github.com/minio/minio-js/blob/master/examples/get-partialobject.mjs)
* [remove-object.js](https://github.com/minio/minio-js/blob/master/examples/remove-object.js)
* [remove-incomplete-upload.js](https://github.com/minio/minio-js/blob/master/examples/remove-incomplete-upload.js)
* [remove-object.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-object.mjs)
* [remove-incomplete-upload.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-incomplete-upload.mjs)
* [stat-object.mjs](https://github.com/minio/minio-js/blob/master/examples/stat-object.mjs)

#### 完整示例 : Presigned操作
* [presigned-getobject.mjs](https://github.com/minio/minio-js/blob/master/examples/presigned-getobject.js)
* [presigned-putobject.mjs](https://github.com/minio/minio-js/blob/master/examples/presigned-putobject.js)
* [presigned-postpolicy.mjs](https://github.com/minio/minio-js/blob/master/examples/presigned-postpolicy.js)
* [presigned-getobject.mjs](https://github.com/minio/minio-js/blob/master/examples/presigned-getobject.mjs)
* [presigned-putobject.mjs](https://github.com/minio/minio-js/blob/master/examples/presigned-putobject.mjs)
* [presigned-postpolicy.mjs](https://github.com/minio/minio-js/blob/master/examples/presigned-postpolicy.mjs)

#### 完整示例 : 存储桶通知
* [get-bucket-notification.js](https://github.com/minio/minio-js/blob/master/examples/get-bucket-notification.js)
* [set-bucket-notification.js](https://github.com/minio/minio-js/blob/master/examples/set-bucket-notification.js)
* [remove-all-bucket-notification.js](https://github.com/minio/minio-js/blob/master/examples/remove-all-bucket-notification.js)
* [listen-bucket-notification.js](https://github.com/minio/minio-js/blob/master/examples/minio/listen-bucket-notification.js) (MinIO Extension)
* [get-bucket-notification.mjs](https://github.com/minio/minio-js/blob/master/examples/get-bucket-notification.mjs)
* [set-bucket-notification.mjs](https://github.com/minio/minio-js/blob/master/examples/set-bucket-notification.mjs)
* [remove-all-bucket-notification.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-all-bucket-notification.mjs)
* [listen-bucket-notification.mjs](https://github.com/minio/minio-js/blob/master/examples/minio/listen-bucket-notification.mjs) (MinIO Extension)

#### 完整示例 : 存储桶策略
* [get-bucket-policy.js](https://github.com/minio/minio-js/blob/master/examples/get-bucket-policy.js)
* [get-bucket-policy.mjs](https://github.com/minio/minio-js/blob/master/examples/get-bucket-policy.mjs)
* [set-bucket-policy.mjs](https://github.com/minio/minio-js/blob/master/examples/set-bucket-policy.mjs)

## 了解更多
Expand Down
2 changes: 1 addition & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@ To stop listening, call `.stop()` on the returned `EventEmitter`.
| `suffix` | _string_ | Object key suffix to filter notifications for. |
| `events` | _Array_ | Enables notifications for specific event types. |

See [here](https://github.com/minio/minio-js/blob/master/examples/minio/listen-bucket-notification.js) for a full example.
See [here](https://github.com/minio/minio-js/blob/master/examples/minio/listen-bucket-notification.mjs) for a full example.

```js
const listener = minioClient.listenBucketNotification('my-bucketname', 'photos/', '.jpg', ['s3:ObjectCreated:*'])
Expand Down
2 changes: 1 addition & 1 deletion docs/zh_CN/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ __参数__
| `suffix` | _string_ | 用于过滤通知的对象名称后缀。 |
| `events` | _Array_ | 在指定事件类型上开启通知。 |

这里是你要的[完整示例](https://github.com/minio/minio-js/blob/master/examples/minio/listen-bucket-notification.js),拿走不谢。
这里是你要的[完整示例](https://github.com/minio/minio-js/blob/master/examples/minio/listen-bucket-notification.mjs),拿走不谢。

```js
const listener = minioClient.listenBucketNotification('my-bucketname', 'photos/', '.jpg', ['s3:ObjectCreated:*'])
Expand Down
10 changes: 2 additions & 8 deletions examples/get-bucket-policy.js → examples/get-bucket-policy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,5 @@ const s3Client = new Minio.Client({
secretKey: 'YOUR-SECRETACCESSKEY',
})

// Retrieves the bucket policy and logs it to the console.
s3Client.getBucketPolicy('testbucket', (err, policy) => {
if (err) {
throw err
}

console.log(`Bucket policy: ${policy}`)
})
const policy = await s3Client.getBucketPolicy('my-bucketname')
console.log(`Bucket policy: ${policy}`)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const s3Client = new Minio.Client({
secretKey: 'YOUR-SECRETACCESSKEY',
})

// List all object paths in bucket my-bucketname that begins with my-prefixname.
// List all incomplete uploads in bucket my-bucketname that begin with my-prefixname.
const incompleteObjectsStream = s3Client.listIncompleteUploads('my-bucketname', 'my-prefixname', true)
incompleteObjectsStream.on('data', function (obj) {
console.log(obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const s3Client = new Minio.Client({
accessKey: 'YOUR-ACCESSKEYID',
secretKey: 'YOUR-SECRETACCESSKEY',
})

// List all object paths in bucket my-bucketname.
const objectsStream = s3Client.extensions.listObjectsV2WithMetadata('my-bucketname', '', true, '')
objectsStream.on('data', function (obj) {
Expand Down
32 changes: 14 additions & 18 deletions examples/list-objects.js → examples/list-objects.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const s3Client = new Minio.Client({
accessKey: 'YOUR-ACCESSKEYID',
secretKey: 'YOUR-SECRETACCESSKEY',
})

// List all object paths in bucket my-bucketname.
const objectsStream = s3Client.listObjects('my-bucketname', '', true)
objectsStream.on('data', function (obj) {
Expand All @@ -43,21 +44,16 @@ objectsStreamWithVersions.on('error', function (e) {
})

// Example to list only the prefixes of a bucket.
//Non versioned bucket with Prefix listing.
function listPrefixesOfABucket(buckName) {
const objectsStream = s3Client.listObjects(buckName, '', false, {})
let counter = 0
objectsStream.on('data', function (obj) {
if (obj.prefix) {
counter += 1
}
})
objectsStream.on('end', () => {
console.log('Non Versioned Prefix Count:', counter)
})
objectsStream.on('error', function (e) {
console.log('::Error:', e)
})
}

listPrefixesOfABucket('your-bucket')
const prefixStream = s3Client.listObjects('your-bucket', '', false, {})
let counter = 0
prefixStream.on('data', function (obj) {
if (obj.prefix) {
counter += 1
}
})
prefixStream.on('end', () => {
console.log('Prefix Count:', counter)
})
prefixStream.on('error', function (e) {
console.log(e)
})
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* limitations under the License.
*/

// Note that `listenBucketNotification` is only available for MinIO, and not
// Amazon.
// Note that `listenBucketNotification` is only available for MinIO, and not Amazon.

import * as Minio from 'minio'

Expand Down Expand Up @@ -55,9 +54,9 @@ poller.on('notification', (record) => {
})

// Create an object - this should trigger a notification.
s3Client.putObject('bucket1', 'file.jpg', 'stringdata', (err, etag) => {
if (err) {
throw err
}
try {
const etag = await s3Client.putObject('bucket1', 'file.jpg', 'stringdata')
console.log(etag)
})
} catch (e) {
console.log(e)
}
62 changes: 0 additions & 62 deletions examples/remove-object.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* MinIO Javascript Library for Amazon S3 Compatible Cloud Storage, (C) 2015 MinIO, Inc.
* MinIO Javascript Library for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,10 +24,34 @@ const s3Client = new Minio.Client({
accessKey: 'YOUR-ACCESSKEYID',
secretKey: 'YOUR-SECRETACCESSKEY',
})
// Remove a partially uploaded object name my-objectname.
s3Client.removeIncompleteUpload('my-bucketname', 'my-objectname', function (e) {
if (e) {
return console.log(e)
}

try {
await s3Client.removeObject('my-bucketname', 'my-objectname')
console.log('Success')
})
} catch (e) {
console.log(e)
}

// Remove an object with a specific versionId.
try {
await s3Client.removeObject('my-bucketname', 'my-objectname', { versionId: 'my-versionId' })
console.log('Success')
} catch (e) {
console.log(e)
}

// Remove an object with retention governance bypass.
try {
await s3Client.removeObject('my-bucketname', 'my-objectname', { versionId: 'my-versionId', governanceBypass: true })
console.log('Success')
} catch (e) {
console.log(e)
}

// Force delete object/prefix.
try {
await s3Client.removeObject('force-del-test', 'test/', { forceDelete: true })
console.log('Success')
} catch (e) {
console.log(e)
}
Loading
Loading