triangle-utils 1.4.2 → 1.4.3
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 +1 -0
- package/dist/src/UtilsS3.js +20 -0
- package/package.json +1 -1
- package/src/UtilsS3.ts +20 -0
package/dist/src/UtilsS3.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare class UtilsS3 {
|
|
|
3
3
|
constructor(region: string);
|
|
4
4
|
file_exists(s3_filename: string): Promise<boolean | undefined>;
|
|
5
5
|
get_file(s3_filename: string): Promise<string | undefined>;
|
|
6
|
+
get_file_stream(s3_filename: string): Promise<(import("node:stream").Readable & import("@smithy/types").SdkStreamMixin) | (Blob & import("@smithy/types").SdkStreamMixin) | (ReadableStream<any> & import("@smithy/types").SdkStreamMixin) | undefined>;
|
|
6
7
|
create_file(s3_filename: string, content: string | Buffer, options?: {
|
|
7
8
|
content_type?: string;
|
|
8
9
|
}): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput | undefined>;
|
package/dist/src/UtilsS3.js
CHANGED
|
@@ -48,6 +48,26 @@ export class UtilsS3 {
|
|
|
48
48
|
throw error;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
async get_file_stream(s3_filename) {
|
|
52
|
+
const s3_key = parse_s3_filename(s3_filename);
|
|
53
|
+
if (s3_key === undefined) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const response = await this.s3.getObject(s3_key);
|
|
58
|
+
const body = response.Body;
|
|
59
|
+
if (body === undefined) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return body;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error instanceof NoSuchKey) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
51
71
|
async create_file(s3_filename, content, options = {}) {
|
|
52
72
|
const content_type = options.content_type !== undefined ? options.content_type : undefined;
|
|
53
73
|
const exists = await this.file_exists(s3_filename);
|
package/package.json
CHANGED
package/src/UtilsS3.ts
CHANGED
|
@@ -58,6 +58,26 @@ export class UtilsS3 {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
async get_file_stream(s3_filename : string) {
|
|
62
|
+
const s3_key = parse_s3_filename(s3_filename)
|
|
63
|
+
if (s3_key === undefined) {
|
|
64
|
+
return undefined
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const response = await this.s3.getObject(s3_key)
|
|
68
|
+
const body = response.Body
|
|
69
|
+
if (body === undefined) {
|
|
70
|
+
return undefined
|
|
71
|
+
}
|
|
72
|
+
return body
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (error instanceof NoSuchKey) {
|
|
75
|
+
return undefined
|
|
76
|
+
}
|
|
77
|
+
throw error
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
61
81
|
async create_file(s3_filename : string, content : string | Buffer, options : {
|
|
62
82
|
content_type? : string
|
|
63
83
|
} = {}) {
|