presidium 0.21.0 → 0.21.1
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/S3.js +58 -0
- package/S3Bucket.js +56 -0
- package/S3Bucket.test.js +5 -0
- package/package.json +1 -1
package/S3.js
CHANGED
|
@@ -157,6 +157,64 @@ S3.prototype.putObject = function s3PutObject(bucketname, key, body, options) {
|
|
|
157
157
|
}).promise()
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* @name S3.prototype.upload
|
|
162
|
+
*
|
|
163
|
+
* @synopsis
|
|
164
|
+
* ```coffeescript [specscript]
|
|
165
|
+
* S3(options).upload(
|
|
166
|
+
* key string,
|
|
167
|
+
* body Buffer|TypedArray|Blob|String|ReadableStream,
|
|
168
|
+
* options? {
|
|
169
|
+
* ACL: 'private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control'
|
|
170
|
+
* CacheControl?: string,
|
|
171
|
+
* ContentDisposition?: string,
|
|
172
|
+
* ContentEncoding?: string,
|
|
173
|
+
* ContentLanguage?: string,
|
|
174
|
+
* ContentLength?: string,
|
|
175
|
+
* ContentMD5?: string,
|
|
176
|
+
* ContentType?: string,
|
|
177
|
+
* ExpectedBucketOwner?: string,
|
|
178
|
+
* Expires?: Date|Date.toString()|number,
|
|
179
|
+
* GrantFullControl?: string,
|
|
180
|
+
* GrantRead?: string,
|
|
181
|
+
* GrantReadACP?: string,
|
|
182
|
+
* GrantWriteACP?: string,
|
|
183
|
+
* Metadata?: Object<string>,
|
|
184
|
+
* ObjectLockLegalHoldStatus?: 'ON'|'OFF',
|
|
185
|
+
* ObjectLockMode?: 'GOVERNANCE'|'COMPLIANCE',
|
|
186
|
+
* ObjectLockRetainUntilDate?: Date|Date.toString()|number,
|
|
187
|
+
* RequestPayer?: requester,
|
|
188
|
+
* SSECustomerAlgorithm?: string,
|
|
189
|
+
* SSECustomerKey?: string|Buffer,
|
|
190
|
+
* SSECustomerKeyMD5?: string,
|
|
191
|
+
* SSEKMSEncryptionContext?: string,
|
|
192
|
+
* SSEKMSKeyId?: string,
|
|
193
|
+
* ServerSideEncryption?: 'AES256'|'aws:kms',
|
|
194
|
+
* StorageClass?: 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA'|'ONEZONE_IA'|'INTELLIGENT_TIERING'|'GLACIER'|'DEEP_ARCHIVE'|'OUTPOSTS'
|
|
195
|
+
* Tagging?: string,
|
|
196
|
+
* WebsiteRedirectLocation?: string,
|
|
197
|
+
* },
|
|
198
|
+
* ) -> Promise<{
|
|
199
|
+
* ETag: string,
|
|
200
|
+
* ServerSideEncryption?: 'AES256'|'aws:kms',
|
|
201
|
+
* VersionId: string,
|
|
202
|
+
* SSECustomerAlgorithm?: string,
|
|
203
|
+
* SSECustomerKey?: string,
|
|
204
|
+
* SSEKMSKeyId?: string,
|
|
205
|
+
* SSEKMSEncryptionContext?: string,
|
|
206
|
+
* RequestCharged?: string,
|
|
207
|
+
* }>
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
S3.prototype.upload = function upload(bucketname, key, body, options) {
|
|
211
|
+
return this.s3.upload({
|
|
212
|
+
Bucket: bucketname,
|
|
213
|
+
Key: key,
|
|
214
|
+
Body: body,
|
|
215
|
+
}).promise()
|
|
216
|
+
}
|
|
217
|
+
|
|
160
218
|
/**
|
|
161
219
|
* @name S3.prototype.deleteObject
|
|
162
220
|
*
|
package/S3Bucket.js
CHANGED
|
@@ -95,6 +95,62 @@ S3Bucket.prototype.putObject = async function s3BucketPutObject(
|
|
|
95
95
|
return this.s3.putObject(this.name, key, body, options)
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* @name S3Bucket.prototype.upload
|
|
100
|
+
*
|
|
101
|
+
* @synopsis
|
|
102
|
+
* ```coffeescript [specscript]
|
|
103
|
+
* S3Bucket(s3).upload(
|
|
104
|
+
* key string,
|
|
105
|
+
* body string|Buffer|ReadableStream,
|
|
106
|
+
* options? {
|
|
107
|
+
* ACL: 'private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control'
|
|
108
|
+
* CacheControl?: string,
|
|
109
|
+
* ContentDisposition?: string,
|
|
110
|
+
* ContentEncoding?: string,
|
|
111
|
+
* ContentLanguage?: string,
|
|
112
|
+
* ContentLength?: string,
|
|
113
|
+
* ContentMD5?: string,
|
|
114
|
+
* ContentType?: string,
|
|
115
|
+
* ExpectedBucketOwner?: string,
|
|
116
|
+
* Expires?: Date|Date.toString()|number,
|
|
117
|
+
* GrantFullControl?: string,
|
|
118
|
+
* GrantRead?: string,
|
|
119
|
+
* GrantReadACP?: string,
|
|
120
|
+
* GrantWriteACP?: string,
|
|
121
|
+
* Metadata?: Object<string>,
|
|
122
|
+
* ObjectLockLegalHoldStatus?: 'ON'|'OFF',
|
|
123
|
+
* ObjectLockMode?: 'GOVERNANCE'|'COMPLIANCE',
|
|
124
|
+
* ObjectLockRetainUntilDate?: Date|Date.toString()|number,
|
|
125
|
+
* RequestPayer?: requester,
|
|
126
|
+
* SSECustomerAlgorithm?: string,
|
|
127
|
+
* SSECustomerKey?: string|Buffer,
|
|
128
|
+
* SSECustomerKeyMD5?: string,
|
|
129
|
+
* SSEKMSEncryptionContext?: string,
|
|
130
|
+
* SSEKMSKeyId?: string,
|
|
131
|
+
* ServerSideEncryption?: 'AES256'|'aws:kms',
|
|
132
|
+
* StorageClass?: 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA'|'ONEZONE_IA'|'INTELLIGENT_TIERING'|'GLACIER'|'DEEP_ARCHIVE'|'OUTPOSTS'
|
|
133
|
+
* Tagging?: string,
|
|
134
|
+
* WebsiteRedirectLocation?: string,
|
|
135
|
+
* },
|
|
136
|
+
* ) -> Promise<{
|
|
137
|
+
* ETag: string,
|
|
138
|
+
* ServerSideEncryption?: 'AES256'|'aws:kms',
|
|
139
|
+
* VersionId: string,
|
|
140
|
+
* SSECustomerAlgorithm?: string,
|
|
141
|
+
* SSECustomerKey?: string,
|
|
142
|
+
* SSEKMSKeyId?: string,
|
|
143
|
+
* SSEKMSEncryptionContext?: string,
|
|
144
|
+
* RequestCharged?: string,
|
|
145
|
+
* }>
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
S3Bucket.prototype.upload = async function upload(key, body, options) {
|
|
149
|
+
await this.ready
|
|
150
|
+
return this.s3.upload(this.name, key, body, options)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
98
154
|
/**
|
|
99
155
|
* @name S3Bucket.prototype.deleteObject
|
|
100
156
|
*
|
package/S3Bucket.test.js
CHANGED
|
@@ -61,6 +61,11 @@ const test = new Test('S3Bucket', S3Bucket)
|
|
|
61
61
|
assert(binary.ContentType == 'application/octet-stream')
|
|
62
62
|
assert.deepEqual(binary.Body, Buffer.from('binary'))
|
|
63
63
|
|
|
64
|
+
const res = await testBucket.upload('buffer', Buffer.from('buffer'))
|
|
65
|
+
const buffer = await testBucket.getObject('buffer')
|
|
66
|
+
assert(buffer.ContentType == 'application/octet-stream')
|
|
67
|
+
assert.deepEqual(buffer.Body, Buffer.from('buffer'))
|
|
68
|
+
|
|
64
69
|
await testBucket.deleteAllObjects({ MaxKeys: 1 })
|
|
65
70
|
const deleted = await testBucket.delete()
|
|
66
71
|
})
|