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.
@@ -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<(import("node:stream").Readable & import("@smithy/types").SdkStreamMixin) | (Blob & import("@smithy/types").SdkStreamMixin) | (ReadableStream<any> & import("@smithy/types").SdkStreamMixin) | undefined>;
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>;
@@ -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
- return body;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "main": "dist/src/index.js",
5
5
  "directories": {
6
6
  "test": "vitest"
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
- return body
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