Skip to content

Commit

Permalink
Fix setFileMetada and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
steevepay committed Jun 16, 2023
1 parent 8962224 commit 7921844
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@ dist
.DS_Store

test.js
*.odt
*.odt
cqueue.js
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v2.2.3
- Patched `setFileMetadata`: Bucket aliases are now supported and are not generating a 403 error anymore.

### v2.2.2
- Patched rock-req options initialisation

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tiny-storage-client",
"version": "2.2.2",
"version": "2.2.3",
"description": "Tiny node client to request distributed AWS S3 or the OpenStack Swift Object Storage.",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ module.exports = (config) => {
let _path = path;
if (options?.alias !== _activeBucket) {
_path = _path.replace(options?.alias, _activeBucket);
/** For copy-ing object with metadatas, the alias must be applied on the URL */
if (options?.headers?.['x-amz-copy-source']) {
options.headers['x-amz-copy-source'] = options?.headers?.['x-amz-copy-source'].replace(options?.alias, _activeBucket);
}
}

const _urlParams = getUrlParameters(options?.queries ?? '', options?.defaultQueries ?? '');
Expand Down
10 changes: 8 additions & 2 deletions tests/s3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2201,8 +2201,14 @@ describe('S3 SDK', function () {

const nockRequestS2 = nock(url1S3, {
reqheaders: {
'x-amz-copy-source': () => true,
'x-amz-metadata-directive': () => true
'x-amz-copy-source': (value) => {
assert.strictEqual(value, '/invoices-gra-1234/file.pdf');
return true
},
'x-amz-metadata-directive': (value) => {
assert.strictEqual(value, "REPLACE");
return true
}
}
})
.defaultReplyHeaders(_headers2)
Expand Down

0 comments on commit 7921844

Please sign in to comment.