triangle-utils 1.4.3 → 1.4.4
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 +2 -1
- package/dist/src/UtilsS3.js +5 -1
- package/package.json +1 -1
- package/src/UtilsS3.ts +6 -2
package/dist/src/UtilsS3.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Readable } from "stream";
|
|
1
2
|
export declare class UtilsS3 {
|
|
2
3
|
private readonly s3;
|
|
3
4
|
constructor(region: string);
|
|
4
5
|
file_exists(s3_filename: string): Promise<boolean | undefined>;
|
|
5
6
|
get_file(s3_filename: string): Promise<string | undefined>;
|
|
6
|
-
get_file_stream(s3_filename: string): Promise<
|
|
7
|
+
get_file_stream(s3_filename: string): Promise<Readable | undefined>;
|
|
7
8
|
create_file(s3_filename: string, content: string | Buffer, options?: {
|
|
8
9
|
content_type?: string;
|
|
9
10
|
}): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput | undefined>;
|
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 { Readable } from "stream";
|
|
3
4
|
function parse_s3_filename(s3_filename) {
|
|
4
5
|
if (s3_filename.substring(0, 5) !== "s3://") {
|
|
5
6
|
return undefined;
|
|
@@ -59,7 +60,10 @@ export class UtilsS3 {
|
|
|
59
60
|
if (body === undefined) {
|
|
60
61
|
return undefined;
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
if (body instanceof Readable) {
|
|
64
|
+
return body;
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
63
67
|
}
|
|
64
68
|
catch (error) {
|
|
65
69
|
if (error instanceof NoSuchKey) {
|
package/package.json
CHANGED
package/src/UtilsS3.ts
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 { Readable } from "stream"
|
|
3
4
|
|
|
4
5
|
interface S3Key {
|
|
5
6
|
Bucket : string,
|
|
@@ -58,7 +59,7 @@ export class UtilsS3 {
|
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
async get_file_stream(s3_filename : string) {
|
|
62
|
+
async get_file_stream(s3_filename : string) : Promise<Readable | undefined> {
|
|
62
63
|
const s3_key = parse_s3_filename(s3_filename)
|
|
63
64
|
if (s3_key === undefined) {
|
|
64
65
|
return undefined
|
|
@@ -69,7 +70,10 @@ export class UtilsS3 {
|
|
|
69
70
|
if (body === undefined) {
|
|
70
71
|
return undefined
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
+
if (body instanceof Readable) {
|
|
74
|
+
return body
|
|
75
|
+
}
|
|
76
|
+
return undefined
|
|
73
77
|
} catch (error) {
|
|
74
78
|
if (error instanceof NoSuchKey) {
|
|
75
79
|
return undefined
|