importer-storage 1.0.3 → 1.0.5

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/index.cjs CHANGED
@@ -90,14 +90,15 @@ function isHttp(url) {
90
90
  var S3Storage = class {
91
91
  saveFiles(keys, options) {
92
92
  return __async(this, null, function* () {
93
- const urls = [];
93
+ const result = [];
94
94
  for (const { key, filePath } of keys) {
95
95
  const s3Key = `${options.savePath}/${key}`;
96
96
  let stream = void 0;
97
97
  let buffer = void 0;
98
98
  if (isHttp(filePath)) {
99
99
  const axiosResponse = yield import_axios.default.get(filePath, {
100
- responseType: "arraybuffer"
100
+ responseType: "arraybuffer",
101
+ headers: options.headers
101
102
  });
102
103
  buffer = Buffer.from(axiosResponse.data);
103
104
  } else {
@@ -114,12 +115,14 @@ var S3Storage = class {
114
115
  ContentType: `image/${extractFileInfo(key).extension}`,
115
116
  ContentDisposition: "inline"
116
117
  });
118
+ result.push({
119
+ key,
120
+ filePath,
121
+ uploadUrl: `https://${BUCKET_NAME}.s3.${process.env.AWS_REGION}.amazonaws.com/${s3Key}`
122
+ });
117
123
  yield s3.send(command);
118
- urls.push(
119
- `https://${BUCKET_NAME}.s3.${process.env.AWS_REGION}.amazonaws.com/${s3Key}`
120
- );
121
124
  }
122
- return { urls: urls.join(",") };
125
+ return { result };
123
126
  });
124
127
  }
125
128
  removeTag(savePath, tags) {
package/dist/index.d.cts CHANGED
@@ -8,7 +8,11 @@ interface IStorage {
8
8
  tags: Array<StorageTag>;
9
9
  savePath: string;
10
10
  }): Promise<{
11
- urls: string;
11
+ result: Array<{
12
+ key: string;
13
+ filePath: string;
14
+ uploadUrl: string;
15
+ }>;
12
16
  }>;
13
17
  removeTag(savePath: string, tags: Array<StorageTag>): Promise<void>;
14
18
  }
@@ -20,8 +24,13 @@ declare class S3Storage implements IStorage {
20
24
  }>, options: {
21
25
  tags: Array<StorageTag>;
22
26
  savePath: string;
27
+ headers?: Record<string, string>;
23
28
  }): Promise<{
24
- urls: string;
29
+ result: {
30
+ key: string;
31
+ filePath: string;
32
+ uploadUrl: string;
33
+ }[];
25
34
  }>;
26
35
  removeTag(savePath: string, tags: Array<StorageTag>): Promise<void>;
27
36
  }
package/dist/index.d.ts CHANGED
@@ -8,7 +8,11 @@ interface IStorage {
8
8
  tags: Array<StorageTag>;
9
9
  savePath: string;
10
10
  }): Promise<{
11
- urls: string;
11
+ result: Array<{
12
+ key: string;
13
+ filePath: string;
14
+ uploadUrl: string;
15
+ }>;
12
16
  }>;
13
17
  removeTag(savePath: string, tags: Array<StorageTag>): Promise<void>;
14
18
  }
@@ -20,8 +24,13 @@ declare class S3Storage implements IStorage {
20
24
  }>, options: {
21
25
  tags: Array<StorageTag>;
22
26
  savePath: string;
27
+ headers?: Record<string, string>;
23
28
  }): Promise<{
24
- urls: string;
29
+ result: {
30
+ key: string;
31
+ filePath: string;
32
+ uploadUrl: string;
33
+ }[];
25
34
  }>;
26
35
  removeTag(savePath: string, tags: Array<StorageTag>): Promise<void>;
27
36
  }
@@ -36672,14 +36672,15 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
36672
36672
  var S3Storage = class {
36673
36673
  saveFiles(keys, options) {
36674
36674
  return __async(this, null, function* () {
36675
- const urls = [];
36675
+ const result = [];
36676
36676
  for (const { key, filePath } of keys) {
36677
36677
  const s3Key = `${options.savePath}/${key}`;
36678
36678
  let stream4 = void 0;
36679
36679
  let buffer = void 0;
36680
36680
  if (isHttp(filePath)) {
36681
36681
  const axiosResponse = yield axios_default.get(filePath, {
36682
- responseType: "arraybuffer"
36682
+ responseType: "arraybuffer",
36683
+ headers: options.headers
36683
36684
  });
36684
36685
  buffer = Buffer.from(axiosResponse.data);
36685
36686
  } else {
@@ -36696,12 +36697,14 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
36696
36697
  ContentType: `image/${extractFileInfo(key).extension}`,
36697
36698
  ContentDisposition: "inline"
36698
36699
  });
36700
+ result.push({
36701
+ key,
36702
+ filePath,
36703
+ uploadUrl: `https://${BUCKET_NAME}.s3.${process.env.AWS_REGION}.amazonaws.com/${s3Key}`
36704
+ });
36699
36705
  yield s32.send(command);
36700
- urls.push(
36701
- `https://${BUCKET_NAME}.s3.${process.env.AWS_REGION}.amazonaws.com/${s3Key}`
36702
- );
36703
36706
  }
36704
- return { urls: urls.join(",") };
36707
+ return { result };
36705
36708
  });
36706
36709
  }
36707
36710
  removeTag(savePath, tags) {
package/dist/index.js CHANGED
@@ -61,14 +61,15 @@ function isHttp(url) {
61
61
  var S3Storage = class {
62
62
  saveFiles(keys, options) {
63
63
  return __async(this, null, function* () {
64
- const urls = [];
64
+ const result = [];
65
65
  for (const { key, filePath } of keys) {
66
66
  const s3Key = `${options.savePath}/${key}`;
67
67
  let stream = void 0;
68
68
  let buffer = void 0;
69
69
  if (isHttp(filePath)) {
70
70
  const axiosResponse = yield axios.get(filePath, {
71
- responseType: "arraybuffer"
71
+ responseType: "arraybuffer",
72
+ headers: options.headers
72
73
  });
73
74
  buffer = Buffer.from(axiosResponse.data);
74
75
  } else {
@@ -85,12 +86,14 @@ var S3Storage = class {
85
86
  ContentType: `image/${extractFileInfo(key).extension}`,
86
87
  ContentDisposition: "inline"
87
88
  });
89
+ result.push({
90
+ key,
91
+ filePath,
92
+ uploadUrl: `https://${BUCKET_NAME}.s3.${process.env.AWS_REGION}.amazonaws.com/${s3Key}`
93
+ });
88
94
  yield s3.send(command);
89
- urls.push(
90
- `https://${BUCKET_NAME}.s3.${process.env.AWS_REGION}.amazonaws.com/${s3Key}`
91
- );
92
95
  }
93
- return { urls: urls.join(",") };
96
+ return { result };
94
97
  });
95
98
  }
96
99
  removeTag(savePath, tags) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "importer-storage",
3
3
  "private": false,
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "main": "dist/index.js",
6
6
  "files": [
7
7
  "dist",