triangle-utils 1.4.114 → 1.4.115
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/dist/src/UtilsS3.d.ts +8 -0
- package/dist/src/UtilsS3.js +17 -0
- package/package.json +4 -3
- package/src/UtilsS3.ts +20 -0
package/dist/src/UtilsS3.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ export declare class UtilsS3 {
|
|
|
15
15
|
ChecksumCRC64NVME?: string | undefined;
|
|
16
16
|
ChecksumSHA1?: string | undefined;
|
|
17
17
|
ChecksumSHA256?: string | undefined;
|
|
18
|
+
ChecksumSHA512?: string | undefined;
|
|
19
|
+
ChecksumMD5?: string | undefined;
|
|
20
|
+
ChecksumXXHASH64?: string | undefined;
|
|
21
|
+
ChecksumXXHASH3?: string | undefined;
|
|
22
|
+
ChecksumXXHASH128?: string | undefined;
|
|
18
23
|
ChecksumType?: import("@aws-sdk/client-s3").ChecksumType | undefined;
|
|
19
24
|
ETag?: string | undefined;
|
|
20
25
|
MissingMeta?: number | undefined;
|
|
@@ -54,6 +59,9 @@ export declare class UtilsS3 {
|
|
|
54
59
|
create(s3_id: string, content: string | Buffer | Readable, options?: {
|
|
55
60
|
content_type_id?: string;
|
|
56
61
|
}): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput | undefined>;
|
|
62
|
+
upload(s3_id: string, content: string | Buffer | Readable, options?: {
|
|
63
|
+
content_type_id?: string;
|
|
64
|
+
}): Promise<void>;
|
|
57
65
|
delete(s3_id: string): Promise<void>;
|
|
58
66
|
get_download_url(s3_id: string): Promise<string | undefined>;
|
|
59
67
|
get_upload_url(s3_id: string, options?: {
|
package/dist/src/UtilsS3.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { S3, NoSuchKey, GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";
|
|
2
2
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
3
|
+
import { Upload } from "@aws-sdk/lib-storage";
|
|
3
4
|
import { Readable } from "stream";
|
|
4
5
|
function get_s3_input(s3_id) {
|
|
5
6
|
const [bucket, path] = (s3_id.match(/^s3\:\/\/([^\/]+)\/([^$]+)$/) || []).slice(1, 3);
|
|
@@ -146,6 +147,22 @@ export class UtilsS3 {
|
|
|
146
147
|
ContentType: content_type_id
|
|
147
148
|
});
|
|
148
149
|
}
|
|
150
|
+
async upload(s3_id, content, options = {}) {
|
|
151
|
+
const content_type_id = options.content_type_id !== undefined ? options.content_type_id : undefined;
|
|
152
|
+
const s3_input = get_s3_input(s3_id);
|
|
153
|
+
if (s3_input === undefined) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
const upload = new Upload({
|
|
157
|
+
client: this.s3,
|
|
158
|
+
params: {
|
|
159
|
+
...s3_input,
|
|
160
|
+
Body: content,
|
|
161
|
+
ContentType: content_type_id
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
await upload.done();
|
|
165
|
+
}
|
|
149
166
|
async delete(s3_id) {
|
|
150
167
|
const s3_input = get_s3_input(s3_id);
|
|
151
168
|
if (s3_input === undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "triangle-utils",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.115",
|
|
4
4
|
"main": "dist/src/index.js",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"directories": {
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
"@aws-sdk/client-bedrock-runtime": "^3.953.0",
|
|
21
21
|
"@aws-sdk/client-cognito-identity-provider": "^3.1004.0",
|
|
22
22
|
"@aws-sdk/client-dynamodb": "^3.953.0",
|
|
23
|
-
"@aws-sdk/client-s3": "^3.
|
|
23
|
+
"@aws-sdk/client-s3": "^3.1106.0",
|
|
24
24
|
"@aws-sdk/client-s3vectors": "^3.953.0",
|
|
25
25
|
"@aws-sdk/client-secrets-manager": "^3.965.0",
|
|
26
26
|
"@aws-sdk/client-ses": "^3.1032.0",
|
|
27
|
-
"@aws-sdk/
|
|
27
|
+
"@aws-sdk/lib-storage": "^3.1106.0",
|
|
28
|
+
"@aws-sdk/s3-request-presigner": "^3.1106.0",
|
|
28
29
|
"@types/jsdom": "^28.0.1",
|
|
29
30
|
"@types/node": "^25.2.3",
|
|
30
31
|
"@types/nodemailer": "^7.0.9",
|
package/src/UtilsS3.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { S3, NoSuchKey, GetObjectCommand, PutObjectCommand, ListObjectsV2CommandOutput, ListObjectsV2CommandInput } from "@aws-sdk/client-s3"
|
|
2
2
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner"
|
|
3
|
+
import { Upload } from "@aws-sdk/lib-storage"
|
|
3
4
|
import { Readable } from "stream"
|
|
4
5
|
|
|
5
6
|
interface S3Input {
|
|
@@ -161,6 +162,25 @@ export class UtilsS3 {
|
|
|
161
162
|
})
|
|
162
163
|
}
|
|
163
164
|
|
|
165
|
+
async upload(s3_id : string, content : string | Buffer | Readable, options : {
|
|
166
|
+
content_type_id? : string
|
|
167
|
+
} = {}) : Promise<void> {
|
|
168
|
+
const content_type_id = options.content_type_id !== undefined ? options.content_type_id : undefined
|
|
169
|
+
const s3_input = get_s3_input(s3_id)
|
|
170
|
+
if (s3_input === undefined) {
|
|
171
|
+
return undefined
|
|
172
|
+
}
|
|
173
|
+
const upload = new Upload({
|
|
174
|
+
client : this.s3,
|
|
175
|
+
params : {
|
|
176
|
+
...s3_input,
|
|
177
|
+
Body : content,
|
|
178
|
+
ContentType : content_type_id
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
await upload.done()
|
|
182
|
+
}
|
|
183
|
+
|
|
164
184
|
async delete(s3_id : string) : Promise<void>{
|
|
165
185
|
const s3_input = get_s3_input(s3_id)
|
|
166
186
|
if (s3_input === undefined) {
|