ag-common 0.0.86 → 0.0.87

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.
@@ -13,3 +13,12 @@ export declare const putS3Object: ({ Body, Bucket, Key, ContentType, }: {
13
13
  Bucket: string;
14
14
  Key: string;
15
15
  }) => Promise<void>;
16
+ export declare const uploadFile: ({ Bucket, Key, Body, }: {
17
+ Bucket: string;
18
+ Key: string;
19
+ Body: string;
20
+ }) => Promise<string>;
21
+ export declare const deleteFile: ({ Bucket, Key, }: {
22
+ Bucket: string;
23
+ Key: string;
24
+ }) => Promise<void>;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.putS3Object = exports.getS3Object = exports.setS3 = void 0;
15
+ exports.deleteFile = exports.uploadFile = exports.putS3Object = exports.getS3Object = exports.setS3 = void 0;
16
16
  const aws_sdk_1 = __importDefault(require("aws-sdk"));
17
17
  let s3 = new aws_sdk_1.default.S3();
18
18
  const setS3 = (region) => {
@@ -35,3 +35,15 @@ const putS3Object = ({ Body, Bucket, Key, ContentType, }) => __awaiter(void 0, v
35
35
  .promise();
36
36
  });
37
37
  exports.putS3Object = putS3Object;
38
+ const uploadFile = ({ Bucket, Key, Body, }) => __awaiter(void 0, void 0, void 0, function* () {
39
+ const res = yield s3.upload({ Bucket, Key, Body }).promise();
40
+ return res.Location;
41
+ });
42
+ exports.uploadFile = uploadFile;
43
+ const deleteFile = ({ Bucket, Key, }) => __awaiter(void 0, void 0, void 0, function* () {
44
+ const res = yield s3.deleteObject({ Bucket, Key }).promise();
45
+ if (res.$response.error) {
46
+ throw res.$response.error;
47
+ }
48
+ });
49
+ exports.deleteFile = deleteFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.86",
3
+ "version": "0.0.87",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",