triangle-utils 1.4.40 → 1.4.41

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.
@@ -3,6 +3,7 @@ export declare class UtilsS3 {
3
3
  private readonly s3;
4
4
  constructor(region: string);
5
5
  file_exists(s3_filename: string): Promise<boolean | undefined>;
6
+ get_file_size(s3_filename: string): Promise<number | undefined>;
6
7
  get_s3_filenames(s3_filename_prefix: string, options?: {
7
8
  compile?: boolean;
8
9
  }): Promise<string[]>;
@@ -28,6 +28,19 @@ export class UtilsS3 {
28
28
  return false;
29
29
  }
30
30
  }
31
+ async get_file_size(s3_filename) {
32
+ const s3_key = parse_s3_filename(s3_filename);
33
+ if (s3_key === undefined) {
34
+ return undefined;
35
+ }
36
+ try {
37
+ const head = await this.s3.headObject(s3_key);
38
+ return head.ContentLength;
39
+ }
40
+ catch (error) {
41
+ return undefined;
42
+ }
43
+ }
31
44
  async get_s3_filenames(s3_filename_prefix, options = {}) {
32
45
  const compile = options.compile !== undefined ? options.compile : false;
33
46
  const s3_key = parse_s3_filename(s3_filename_prefix);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.40",
3
+ "version": "1.4.41",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/UtilsS3.ts CHANGED
@@ -38,6 +38,19 @@ export class UtilsS3 {
38
38
  }
39
39
  }
40
40
 
41
+ async get_file_size(s3_filename : string) : Promise<number | undefined> {
42
+ const s3_key = parse_s3_filename(s3_filename)
43
+ if (s3_key === undefined) {
44
+ return undefined
45
+ }
46
+ try {
47
+ const head = await this.s3.headObject(s3_key)
48
+ return head.ContentLength
49
+ } catch (error) {
50
+ return undefined
51
+ }
52
+ }
53
+
41
54
  async get_s3_filenames(s3_filename_prefix : string, options : { compile? : boolean } = {}) {
42
55
  const compile = options.compile !== undefined ? options.compile : false
43
56
  const s3_key = parse_s3_filename(s3_filename_prefix)