Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: putBucketInventory supports new fields #1290

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* eslint max-len: [0] */
// Ignore checking the js file generated by ts
const buckets = ['dataIndex.js'];
const ignorePatterns = ['lib/common/utils/*.js'].concat(buckets.map(item => `lib/common/bucket/${item}`));

module.exports = {
ignorePatterns,
extends: ['airbnb', 'eslint-config-ali/typescript', 'prettier'],
parserOptions: {
ecmaFeatures: {
Expand All @@ -16,7 +20,6 @@ module.exports = {
},
rules: {
indent: ['error', 2],
// override default options
'no-underscore-dangle': [0],
'no-plusplus': [0],
'no-return-await': [0],
Expand Down
96 changes: 64 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ try {
const putObjectResult = await store.put('your bucket name', 'your object name', {
headers: {
// The headers of this request
'header1': 'value1',
'header2': 'value2'
header1: 'value1',
header2: 'value2'
},
// The keys of the request headers that need to be calculated into the V4 signature. Please ensure that these additional headers are included in the request headers.
additionalHeaders: ['additional header1', 'additional header2']
Expand Down Expand Up @@ -1489,7 +1489,8 @@ Success will return:
- res {Object} response info

```ts
type Field = 'Size | LastModifiedDate | ETag | StorageClass | IsMultipartUploaded | EncryptionStatus';
type Field =
'Size | LastModifiedDate | ETag | StorageClass | IsMultipartUploaded | EncryptionStatus | ObjectAcl | TaggingCount | ObjectType | Crc64';
interface Inventory {
id: string;
isEnabled: true | false;
Expand Down Expand Up @@ -1538,7 +1539,18 @@ const inventory = {
frequency: 'Daily', // `WEEKLY` | `Daily`
includedObjectVersions: 'All', // `All` | `Current`
optionalFields: {
field: ['Size', 'LastModifiedDate', 'ETag', 'StorageClass', 'IsMultipartUploaded', 'EncryptionStatus']
field: [
'Size',
'LastModifiedDate',
'ETag',
'StorageClass',
'IsMultipartUploaded',
'EncryptionStatus',
'ObjectAcl',
'TaggingCount',
'ObjectType',
'Crc64'
]
}
};

Expand Down Expand Up @@ -2671,13 +2683,17 @@ const url = store.signatureUrl('ossdemo.txt', {
console.log(url);

// --------------------------------------------------
const url = store.signatureUrl('ossdemo.txt', {
expires: 3600,
response: {
'content-type': 'text/custom',
'content-disposition': 'attachment'
}
}, false);
const url = store.signatureUrl(
'ossdemo.txt',
{
expires: 3600,
response: {
'content-type': 'text/custom',
'content-disposition': 'attachment'
}
},
false
);
console.log(url);

// put operation
Expand Down Expand Up @@ -2750,13 +2766,17 @@ const url = await store.asyncSignatureUrl('ossdemo.txt', {
});
console.log(url);
// --------------------------------------------------
const url = await store.asyncSignatureUrl('ossdemo.txt', {
expires: 3600,
response: {
'content-type': 'text/custom',
'content-disposition': 'attachment'
}
}, false);
const url = await store.asyncSignatureUrl(
'ossdemo.txt',
{
expires: 3600,
response: {
'content-type': 'text/custom',
'content-disposition': 'attachment'
}
},
false
);
console.log(url);
// put operation
```
Expand Down Expand Up @@ -2799,28 +2819,40 @@ example:
const getObjectUrl = await store.signatureUrlV4('GET', 60, undefined, 'your obejct name');
console.log(getObjectUrl);
// --------------------------------------------------
const getObjectUrl = await store.signatureUrlV4('GET', 60, {
headers: {
'Cache-Control': 'no-cache'
const getObjectUrl = await store.signatureUrlV4(
'GET',
60,
{
headers: {
'Cache-Control': 'no-cache'
},
queries: {
versionId: 'version ID of your object'
}
},
queries: {
versionId: 'version ID of your object'
}
}, 'your obejct name', ['Cache-Control']);
'your obejct name',
['Cache-Control']
);
console.log(getObjectUrl);

// -------------------------------------------------
// PutObject
const putObejctUrl = await store.signatureUrlV4('PUT', 60, undefined, 'your obejct name');
console.log(putObejctUrl);
// --------------------------------------------------
const putObejctUrl = await store.signatureUrlV4('PUT', 60, {
headers: {
'Content-Type': 'text/plain',
'Content-MD5': 'xxx',
'Content-Length': 1
}
}, 'your obejct name', ['Content-Length']);
const putObejctUrl = await store.signatureUrlV4(
'PUT',
60,
{
headers: {
'Content-Type': 'text/plain',
'Content-MD5': 'xxx',
'Content-Length': 1
}
},
'your obejct name',
['Content-Length']
);
console.log(putObejctUrl);
```

Expand Down
2 changes: 1 addition & 1 deletion lib/common/bucket/putBucketInventory.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare type Field = 'Size | LastModifiedDate | ETag | StorageClass | IsMultipartUploaded | EncryptionStatus';
declare type Field = 'Size | LastModifiedDate | ETag | StorageClass | IsMultipartUploaded | EncryptionStatus | ObjectAcl | TaggingCount | ObjectType | Crc64';
interface Inventory {
id: string;
isEnabled: true | false;
Expand Down
3 changes: 2 additions & 1 deletion lib/common/bucket/putBucketInventory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { checkBucketName } from '../utils/checkBucketName';
import { obj2xml } from '../utils/obj2xml';

type Field = 'Size | LastModifiedDate | ETag | StorageClass | IsMultipartUploaded | EncryptionStatus';
type Field =
'Size | LastModifiedDate | ETag | StorageClass | IsMultipartUploaded | EncryptionStatus | ObjectAcl | TaggingCount | ObjectType | Crc64';

interface Inventory {
id: string;
Expand Down