importer-storage 1.0.5 → 1.0.7
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 +10 -1
- package/dist/index.global.js +47102 -7291
- package/dist/index.js +10 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -59,6 +59,7 @@ var import_client_s3 = require("@aws-sdk/client-s3");
|
|
|
59
59
|
var import_fs = require("fs");
|
|
60
60
|
var import_dotenv = require("dotenv");
|
|
61
61
|
var import_axios = __toESM(require("axios"), 1);
|
|
62
|
+
var import_jimp = require("jimp");
|
|
62
63
|
(0, import_dotenv.config)();
|
|
63
64
|
if (!process.env.AWS_ACCESS_KEY_ID) {
|
|
64
65
|
throw new Error("'AWS_ACCESS_KEY_ID' not set");
|
|
@@ -107,13 +108,21 @@ var S3Storage = class {
|
|
|
107
108
|
const tagString = options.tags.map(
|
|
108
109
|
(tag) => `${encodeURIComponent(tag.split(":")[0])}=${encodeURIComponent(tag.split(":")[1])}`
|
|
109
110
|
).join("&");
|
|
111
|
+
if (!stream && !buffer) {
|
|
112
|
+
throw new Error("buffer or stream not set");
|
|
113
|
+
}
|
|
114
|
+
const image = buffer ? yield import_jimp.Jimp.fromBuffer(buffer) : yield import_jimp.Jimp.read(filePath);
|
|
110
115
|
const command = new import_client_s3.PutObjectCommand({
|
|
111
116
|
Body: buffer || stream,
|
|
112
117
|
Bucket: BUCKET_NAME,
|
|
113
118
|
Key: s3Key,
|
|
114
119
|
Tagging: tagString || void 0,
|
|
115
120
|
ContentType: `image/${extractFileInfo(key).extension}`,
|
|
116
|
-
ContentDisposition: "inline"
|
|
121
|
+
ContentDisposition: "inline",
|
|
122
|
+
Metadata: {
|
|
123
|
+
"img-width": image.width.toString(),
|
|
124
|
+
"img-height": image.height.toString()
|
|
125
|
+
}
|
|
117
126
|
});
|
|
118
127
|
result.push({
|
|
119
128
|
key,
|