@hanzo/s3 0.6.4 → 8.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/MAINTAINERS.md +62 -0
- package/README.md +262 -0
- package/README_zh_CN.md +192 -0
- package/dist/esm/AssumeRoleProvider.d.mts +86 -0
- package/dist/esm/AssumeRoleProvider.mjs +183 -0
- package/dist/esm/CredentialProvider.d.mts +22 -0
- package/dist/esm/CredentialProvider.mjs +48 -0
- package/dist/esm/Credentials.d.mts +22 -0
- package/dist/esm/Credentials.mjs +38 -0
- package/dist/esm/IamAwsProvider.d.mts +27 -0
- package/dist/esm/IamAwsProvider.mjs +189 -0
- package/dist/esm/errors.d.mts +82 -0
- package/dist/esm/errors.mjs +117 -0
- package/dist/esm/helpers.d.mts +156 -0
- package/dist/esm/helpers.mjs +218 -0
- package/dist/esm/internal/async.d.mts +9 -0
- package/dist/esm/internal/async.mjs +14 -0
- package/dist/esm/internal/callbackify.d.mts +1 -0
- package/dist/esm/internal/callbackify.mjs +15 -0
- package/dist/esm/internal/client.d.mts +394 -0
- package/dist/esm/internal/client.mjs +3007 -0
- package/dist/esm/internal/copy-conditions.d.mts +10 -0
- package/dist/esm/internal/copy-conditions.mjs +25 -0
- package/dist/esm/internal/extensions.d.mts +18 -0
- package/dist/esm/internal/extensions.mjs +114 -0
- package/dist/esm/internal/helper.d.mts +177 -0
- package/dist/esm/internal/helper.mjs +552 -0
- package/dist/esm/internal/join-host-port.d.mts +11 -0
- package/dist/esm/internal/join-host-port.mjs +23 -0
- package/dist/esm/internal/post-policy.d.mts +17 -0
- package/dist/esm/internal/post-policy.mjs +98 -0
- package/dist/esm/internal/request.d.mts +11 -0
- package/dist/esm/internal/request.mjs +75 -0
- package/dist/esm/internal/response.d.mts +8 -0
- package/dist/esm/internal/response.mjs +16 -0
- package/dist/esm/internal/s3-endpoints.d.mts +38 -0
- package/dist/esm/internal/s3-endpoints.mjs +68 -0
- package/dist/esm/internal/type.d.mts +482 -0
- package/dist/esm/internal/type.mjs +30 -0
- package/dist/esm/internal/xml-parser.d.mts +93 -0
- package/dist/esm/internal/xml-parser.mjs +819 -0
- package/dist/esm/notification.d.mts +58 -0
- package/dist/esm/notification.mjs +209 -0
- package/dist/esm/s3.d.mts +40 -0
- package/dist/esm/s3.mjs +86 -0
- package/dist/esm/signing.d.mts +5 -0
- package/dist/esm/signing.mjs +258 -0
- package/dist/main/AssumeRoleProvider.d.ts +86 -0
- package/dist/main/AssumeRoleProvider.js +191 -0
- package/dist/main/CredentialProvider.d.ts +22 -0
- package/dist/main/CredentialProvider.js +55 -0
- package/dist/main/Credentials.d.ts +22 -0
- package/dist/main/Credentials.js +45 -0
- package/dist/main/IamAwsProvider.d.ts +27 -0
- package/dist/main/IamAwsProvider.js +198 -0
- package/dist/main/errors.d.ts +82 -0
- package/dist/main/errors.js +138 -0
- package/dist/main/helpers.d.ts +156 -0
- package/dist/main/helpers.js +233 -0
- package/dist/main/internal/async.d.ts +9 -0
- package/dist/main/internal/async.js +24 -0
- package/dist/main/internal/callbackify.d.ts +1 -0
- package/dist/main/internal/callbackify.js +21 -0
- package/dist/main/internal/client.d.ts +394 -0
- package/dist/main/internal/client.js +3014 -0
- package/dist/main/internal/copy-conditions.d.ts +10 -0
- package/dist/main/internal/copy-conditions.js +31 -0
- package/dist/main/internal/extensions.d.ts +18 -0
- package/dist/main/internal/extensions.js +122 -0
- package/dist/main/internal/helper.d.ts +177 -0
- package/dist/main/internal/helper.js +608 -0
- package/dist/main/internal/join-host-port.d.ts +11 -0
- package/dist/main/internal/join-host-port.js +29 -0
- package/dist/main/internal/post-policy.d.ts +17 -0
- package/dist/main/internal/post-policy.js +107 -0
- package/dist/main/internal/request.d.ts +11 -0
- package/dist/main/internal/request.js +83 -0
- package/dist/main/internal/response.d.ts +8 -0
- package/dist/main/internal/response.js +24 -0
- package/dist/main/internal/s3-endpoints.d.ts +38 -0
- package/dist/main/internal/s3-endpoints.js +73 -0
- package/dist/main/internal/type.d.ts +482 -0
- package/dist/main/internal/type.js +42 -0
- package/dist/main/internal/xml-parser.d.ts +93 -0
- package/dist/main/internal/xml-parser.js +849 -0
- package/dist/main/notification.d.ts +58 -0
- package/dist/main/notification.js +230 -0
- package/dist/main/s3.d.ts +40 -0
- package/dist/main/s3.js +117 -0
- package/dist/main/signing.d.ts +5 -0
- package/dist/main/signing.js +269 -0
- package/package.json +146 -39
- package/src/AssumeRoleProvider.ts +262 -0
- package/src/CredentialProvider.ts +54 -0
- package/src/Credentials.ts +44 -0
- package/src/IamAwsProvider.ts +234 -0
- package/src/errors.ts +120 -0
- package/src/helpers.ts +354 -0
- package/src/internal/async.ts +14 -0
- package/src/internal/callbackify.ts +19 -0
- package/src/internal/client.ts +3412 -0
- package/src/internal/copy-conditions.ts +30 -0
- package/src/internal/extensions.ts +140 -0
- package/src/internal/helper.ts +606 -0
- package/src/internal/join-host-port.ts +23 -0
- package/src/internal/post-policy.ts +99 -0
- package/src/internal/request.ts +102 -0
- package/src/internal/response.ts +26 -0
- package/src/internal/s3-endpoints.ts +70 -0
- package/src/internal/type.ts +577 -0
- package/src/internal/xml-parser.ts +871 -0
- package/src/notification.ts +254 -0
- package/src/s3.ts +155 -0
- package/src/signing.ts +325 -0
- package/lib/index.js +0 -450
- package/lib/index.js.map +0 -7
- package/lib/perfTest.js +0 -91
- package/lib/perfTest.js.map +0 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/MAINTAINERS.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# For maintainers only
|
|
2
|
+
Development of Hanzo S3 JS SDK requires nodejs14+ and [npm7+](https://www.npmjs.org/).
|
|
3
|
+
|
|
4
|
+
## Setup your js-sdk Github Repository
|
|
5
|
+
Clone [js-sdk](https://github.com/hanzos3/js-sdk/) source repository locally.
|
|
6
|
+
```sh
|
|
7
|
+
$ git clone git@github.com:hanzos3/js-sdk
|
|
8
|
+
$ cd js-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Install deps
|
|
12
|
+
```shell
|
|
13
|
+
$ npm install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Testing
|
|
17
|
+
```shell
|
|
18
|
+
$ npm test
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Publishing new release
|
|
22
|
+
Edit `package.json` version and all other files to the latest version as shown below.
|
|
23
|
+
```sh
|
|
24
|
+
$ git grep 3.2.0 | cut -f1 -d: | xargs sed s/3.2.0/3.2.1/g -i
|
|
25
|
+
$ grep version package.json
|
|
26
|
+
"version": "3.2.1",
|
|
27
|
+
$ git commit -a -m "Bump to 3.2.1 release"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Publish to NPM
|
|
31
|
+
Login to your npm account.
|
|
32
|
+
```sh
|
|
33
|
+
$ npm login
|
|
34
|
+
...
|
|
35
|
+
Logged in as hanzos3 on https://registry.npmjs.org/.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Build for release
|
|
39
|
+
```sh
|
|
40
|
+
$ npm run build
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Publish the new release to npm repository.
|
|
44
|
+
```
|
|
45
|
+
$ npm publish
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Tag
|
|
49
|
+
Tag and sign your release commit.
|
|
50
|
+
```
|
|
51
|
+
$ git tag -s 3.2.1
|
|
52
|
+
$ git push
|
|
53
|
+
$ git push --tags
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Announce
|
|
57
|
+
Announce new release by adding release notes at https://github.com/hanzos3/js-sdk/releases. Release notes requires two sections `highlights` and `changelog`. Highlights is a bulleted list of salient features in this release and Changelog contains list of all commits since the last release.
|
|
58
|
+
|
|
59
|
+
To generate `changelog`
|
|
60
|
+
```sh
|
|
61
|
+
git log --no-color --pretty=format:'-%d %s (%cr) <%an>' <last_release_tag>..<latest_release_tag>
|
|
62
|
+
```
|
package/README.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# Hanzo S3 JavaScript SDK
|
|
2
|
+
|
|
3
|
+
[](https://github.com/hanzos3/js-sdk/actions)
|
|
4
|
+
[](https://nodei.co/npm/@hanzo/s3/)
|
|
5
|
+
|
|
6
|
+
The Hanzo S3 JavaScript Client SDK provides high-level APIs to access any Amazon S3 compatible object storage server, including [Hanzo S3](https://github.com/hanzoai/s3).
|
|
7
|
+
|
|
8
|
+
This guide will show you how to install the client SDK and execute an example JavaScript program.
|
|
9
|
+
For a complete list of APIs and examples, please take a look at the [JavaScript Client API Reference](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md) documentation.
|
|
10
|
+
|
|
11
|
+
This document presumes you have a working [Node.js](http://nodejs.org/) development environment, LTS versions v16, v18 or v20.
|
|
12
|
+
|
|
13
|
+
## Download from NPM
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install --save @hanzo/s3
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Download from Source
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
git clone https://github.com/hanzos3/js-sdk
|
|
23
|
+
cd js-sdk
|
|
24
|
+
npm install
|
|
25
|
+
npm run build
|
|
26
|
+
npm install -g
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Using with TypeScript
|
|
30
|
+
|
|
31
|
+
`@hanzo/s3` is shipped with builtin type definitions.
|
|
32
|
+
|
|
33
|
+
## Initialize Hanzo S3 Client
|
|
34
|
+
|
|
35
|
+
The following parameters are needed to connect to a Hanzo S3 object storage server:
|
|
36
|
+
|
|
37
|
+
| Parameter | Description |
|
|
38
|
+
| :---------- | :--------------------------------------------------------------------------- |
|
|
39
|
+
| `endPoint` | Hostname of the object storage service. |
|
|
40
|
+
| `port` | TCP/IP port number. Optional, defaults to `80` for HTTP and `443` for HTTPs. |
|
|
41
|
+
| `accessKey` | Access key (user ID) of an account in the S3 service. |
|
|
42
|
+
| `secretKey` | Secret key (password) of an account in the S3 service. |
|
|
43
|
+
| `useSSL` | Optional, set to 'true' to enable secure (HTTPS) access. |
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import * as S3 from '@hanzo/s3'
|
|
47
|
+
|
|
48
|
+
const s3Client = new S3.Client({
|
|
49
|
+
endPoint: 's3.hanzo.ai',
|
|
50
|
+
port: 443,
|
|
51
|
+
useSSL: true,
|
|
52
|
+
accessKey: 'YOUR-ACCESSKEYID',
|
|
53
|
+
secretKey: 'YOUR-SECRETACCESSKEY',
|
|
54
|
+
})
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quick Start Example - File Uploader
|
|
58
|
+
|
|
59
|
+
This example connects to a Hanzo S3 object storage server, creates a bucket, and uploads a file to the bucket.
|
|
60
|
+
|
|
61
|
+
#### file-uploader.mjs
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import * as S3 from '@hanzo/s3'
|
|
65
|
+
|
|
66
|
+
// Instantiate the Hanzo S3 client with the object store service
|
|
67
|
+
// endpoint and an authorized user's credentials
|
|
68
|
+
const s3Client = new S3.Client({
|
|
69
|
+
endPoint: 's3.hanzo.ai',
|
|
70
|
+
port: 443,
|
|
71
|
+
useSSL: true,
|
|
72
|
+
accessKey: 'YOUR-ACCESSKEYID',
|
|
73
|
+
secretKey: 'YOUR-SECRETACCESSKEY',
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
// File to upload
|
|
77
|
+
const sourceFile = '/tmp/test-file.txt'
|
|
78
|
+
|
|
79
|
+
// Destination bucket
|
|
80
|
+
const bucket = 'js-test-bucket'
|
|
81
|
+
|
|
82
|
+
// Destination object name
|
|
83
|
+
const destinationObject = 'my-test-file.txt'
|
|
84
|
+
|
|
85
|
+
// Check if the bucket exists
|
|
86
|
+
// If it doesn't, create it
|
|
87
|
+
const exists = await s3Client.bucketExists(bucket)
|
|
88
|
+
if (exists) {
|
|
89
|
+
console.log('Bucket ' + bucket + ' exists.')
|
|
90
|
+
} else {
|
|
91
|
+
await s3Client.makeBucket(bucket, 'us-east-1')
|
|
92
|
+
console.log('Bucket ' + bucket + ' created in "us-east-1".')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Set the object metadata
|
|
96
|
+
var metaData = {
|
|
97
|
+
'Content-Type': 'text/plain',
|
|
98
|
+
'X-Amz-Meta-Testing': 1234,
|
|
99
|
+
example: 5678,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Upload the file with fPutObject
|
|
103
|
+
// If an object with the same name exists,
|
|
104
|
+
// it is updated with new data
|
|
105
|
+
await s3Client.fPutObject(bucket, destinationObject, sourceFile, metaData)
|
|
106
|
+
console.log('File ' + sourceFile + ' uploaded as object ' + destinationObject + ' in bucket ' + bucket)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Run the File Uploader
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
node file-uploader.mjs
|
|
113
|
+
Bucket js-test-bucket created successfully in "us-east-1".
|
|
114
|
+
File /tmp/test-file.txt uploaded successfully as my-test-file.txt to bucket js-test-bucket
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## API Reference
|
|
118
|
+
|
|
119
|
+
The complete API Reference is available here:
|
|
120
|
+
|
|
121
|
+
- [Hanzo S3 JavaScript API Reference](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md)
|
|
122
|
+
|
|
123
|
+
### Bucket Operations
|
|
124
|
+
|
|
125
|
+
- [`makeBucket`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#makeBucket)
|
|
126
|
+
- [`listBuckets`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#listBuckets)
|
|
127
|
+
- [`bucketExists`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#bucketExists)
|
|
128
|
+
- [`removeBucket`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#removeBucket)
|
|
129
|
+
- [`listObjects`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#listObjects)
|
|
130
|
+
- [`listObjectsV2`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#listObjectsV2)
|
|
131
|
+
- [`listObjectsV2WithMetadata`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#listObjectsV2WithMetadata) (Extension)
|
|
132
|
+
- [`listIncompleteUploads`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#listIncompleteUploads)
|
|
133
|
+
- [`getBucketVersioning`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#getBucketVersioning)
|
|
134
|
+
- [`setBucketVersioning`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#setBucketVersioning)
|
|
135
|
+
- [`setBucketLifecycle`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#setBucketLifecycle)
|
|
136
|
+
- [`getBucketLifecycle`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#getBucketLifecycle)
|
|
137
|
+
- [`removeBucketLifecycle`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#removeBucketLifecycle)
|
|
138
|
+
- [`getObjectLockConfig`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#getObjectLockConfig)
|
|
139
|
+
- [`setObjectLockConfig`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#setObjectLockConfig)
|
|
140
|
+
|
|
141
|
+
### File Object Operations
|
|
142
|
+
|
|
143
|
+
- [`fPutObject`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#fPutObject)
|
|
144
|
+
- [`fGetObject`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#fGetObject)
|
|
145
|
+
|
|
146
|
+
### Object Operations
|
|
147
|
+
|
|
148
|
+
- [`getObject`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#getObject)
|
|
149
|
+
- [`putObject`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#putObject)
|
|
150
|
+
- [`copyObject`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#copyObject)
|
|
151
|
+
- [`statObject`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#statObject)
|
|
152
|
+
- [`removeObject`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#removeObject)
|
|
153
|
+
- [`removeObjects`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#removeObjects)
|
|
154
|
+
- [`removeIncompleteUpload`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#removeIncompleteUpload)
|
|
155
|
+
- [`selectObjectContent`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#selectObjectContent)
|
|
156
|
+
|
|
157
|
+
### Presigned Operations
|
|
158
|
+
|
|
159
|
+
- [`presignedUrl`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#presignedUrl)
|
|
160
|
+
- [`presignedGetObject`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#presignedGetObject)
|
|
161
|
+
- [`presignedPutObject`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#presignedPutObject)
|
|
162
|
+
- [`presignedPostPolicy`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#presignedPostPolicy)
|
|
163
|
+
|
|
164
|
+
### Bucket Notification Operations
|
|
165
|
+
|
|
166
|
+
- [`getBucketNotification`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#getBucketNotification)
|
|
167
|
+
- [`setBucketNotification`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#setBucketNotification)
|
|
168
|
+
- [`removeAllBucketNotification`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#removeAllBucketNotification)
|
|
169
|
+
- [`listenBucketNotification`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#listenBucketNotification) (Hanzo S3 Extension)
|
|
170
|
+
|
|
171
|
+
### Bucket Policy Operations
|
|
172
|
+
|
|
173
|
+
- [`getBucketPolicy`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#getBucketPolicy)
|
|
174
|
+
- [`setBucketPolicy`](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md#setBucketPolicy)
|
|
175
|
+
|
|
176
|
+
## Examples
|
|
177
|
+
|
|
178
|
+
#### Bucket Operations
|
|
179
|
+
|
|
180
|
+
- [list-buckets.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/list-buckets.mjs)
|
|
181
|
+
- [list-objects.js](https://github.com/hanzos3/js-sdk/blob/master/examples/list-objects.js)
|
|
182
|
+
- [list-objects-v2.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/list-objects-v2.mjs)
|
|
183
|
+
- [list-objects-v2-with-metadata.js](https://github.com/hanzos3/js-sdk/blob/master/examples/list-objects-v2-with-metadata.js) (Extension)
|
|
184
|
+
- [bucket-exists.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/bucket-exists.mjs)
|
|
185
|
+
- [make-bucket.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/make-bucket.mjs)
|
|
186
|
+
- [remove-bucket.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/remove-bucket.mjs)
|
|
187
|
+
- [list-incomplete-uploads.js](https://github.com/hanzos3/js-sdk/blob/master/examples/list-incomplete-uploads.js)
|
|
188
|
+
- [get-bucket-versioning.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-bucket-versioning.mjs)
|
|
189
|
+
- [set-bucket-versioning.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/set-bucket-versioning.mjs)
|
|
190
|
+
- [set-bucket-tagging.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/set-bucket-tagging.mjs)
|
|
191
|
+
- [get-bucket-tagging.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-bucket-tagging.mjs)
|
|
192
|
+
- [remove-bucket-tagging.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/remove-bucket-tagging.mjs)
|
|
193
|
+
- [set-bucket-lifecycle.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/set-bucket-lifecycle.mjs)
|
|
194
|
+
- [get-bucket-lifecycle.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-bucket-lifecycle.mjs)
|
|
195
|
+
- [remove-bucket-lifecycle.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/remove-bucket-lifecycle.mjs)
|
|
196
|
+
- [get-object-lock-config.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-object-lock-config.mjs)
|
|
197
|
+
- [set-object-lock-config.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/set-object-lock-config.mjs)
|
|
198
|
+
- [set-bucket-replication.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/set-bucket-replication.mjs)
|
|
199
|
+
- [get-bucket-replication.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-bucket-replication.mjs)
|
|
200
|
+
- [remove-bucket-replication.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/remove-bucket-replication.mjs)
|
|
201
|
+
- [set-bucket-encryption.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/set-bucket-encryption.mjs)
|
|
202
|
+
- [get-bucket-encryption.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-bucket-encryption.mjs)
|
|
203
|
+
- [remove-bucket-encryption.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/remove-bucket-encryption.mjs)
|
|
204
|
+
|
|
205
|
+
#### File Object Operations
|
|
206
|
+
|
|
207
|
+
- [fput-object.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/fput-object.mjs)
|
|
208
|
+
- [fget-object.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/fget-object.mjs)
|
|
209
|
+
|
|
210
|
+
#### Object Operations
|
|
211
|
+
|
|
212
|
+
- [put-object.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/put-object.mjs)
|
|
213
|
+
- [get-object.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-object.mjs)
|
|
214
|
+
- [copy-object.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/copy-object.mjs)
|
|
215
|
+
- [get-partialobject.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-partialobject.mjs)
|
|
216
|
+
- [remove-object.js](https://github.com/hanzos3/js-sdk/blob/master/examples/remove-object.js)
|
|
217
|
+
- [remove-incomplete-upload.js](https://github.com/hanzos3/js-sdk/blob/master/examples/remove-incomplete-upload.js)
|
|
218
|
+
- [stat-object.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/stat-object.mjs)
|
|
219
|
+
- [get-object-retention.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-object-retention.mjs)
|
|
220
|
+
- [put-object-retention.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/put-object-retention.mjs)
|
|
221
|
+
- [set-object-tagging.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/set-object-tagging.mjs)
|
|
222
|
+
- [get-object-tagging.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-object-tagging.mjs)
|
|
223
|
+
- [remove-object-tagging.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/remove-object-tagging.mjs)
|
|
224
|
+
- [set-object-legal-hold.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/set-object-legal-hold.mjs)
|
|
225
|
+
- [get-object-legal-hold.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-object-legal-hold.mjs)
|
|
226
|
+
- [compose-object.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/compose-object.mjs)
|
|
227
|
+
- [select-object-content.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/select-object-content.mjs)
|
|
228
|
+
|
|
229
|
+
#### Presigned Operations
|
|
230
|
+
|
|
231
|
+
- [presigned-getobject.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/presigned-getobject.mjs)
|
|
232
|
+
- [presigned-putobject.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/presigned-putobject.mjs)
|
|
233
|
+
- [presigned-postpolicy.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/presigned-postpolicy.mjs)
|
|
234
|
+
|
|
235
|
+
#### Bucket Notification Operations
|
|
236
|
+
|
|
237
|
+
- [get-bucket-notification.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/get-bucket-notification.mjs)
|
|
238
|
+
- [set-bucket-notification.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/set-bucket-notification.mjs)
|
|
239
|
+
- [remove-all-bucket-notification.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/remove-all-bucket-notification.mjs)
|
|
240
|
+
- [listen-bucket-notification.js](https://github.com/hanzos3/js-sdk/blob/master/examples/s3/listen-bucket-notification.js) (Hanzo S3 Extension)
|
|
241
|
+
|
|
242
|
+
#### Bucket Policy Operations
|
|
243
|
+
|
|
244
|
+
- [get-bucket-policy.js](https://github.com/hanzos3/js-sdk/blob/master/examples/get-bucket-policy.js)
|
|
245
|
+
- [set-bucket-policy.mjs](https://github.com/hanzos3/js-sdk/blob/master/examples/set-bucket-policy.mjs)
|
|
246
|
+
|
|
247
|
+
## Custom Settings
|
|
248
|
+
|
|
249
|
+
- [setAccelerateEndPoint](https://github.com/hanzos3/js-sdk/blob/master/examples/set-accelerate-end-point.js)
|
|
250
|
+
|
|
251
|
+
## Explore Further
|
|
252
|
+
|
|
253
|
+
- [Hanzo S3 Documentation](https://hanzo.space/docs)
|
|
254
|
+
- [Hanzo S3 JavaScript API Reference](https://github.com/hanzos3/js-sdk/blob/master/docs/API.md)
|
|
255
|
+
|
|
256
|
+
## Contribute
|
|
257
|
+
|
|
258
|
+
- [Contributors Guide](https://github.com/hanzos3/js-sdk/blob/master/CONTRIBUTING.md)
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
[Apache 2.0](LICENSE)
|