drapcode-utility 2.2.1 → 2.3.0
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.
|
@@ -132,6 +132,7 @@ const drapcodeEncryptDecrypt = async (data, encrypt) => {
|
|
|
132
132
|
};
|
|
133
133
|
exports.drapcodeEncryptDecrypt = drapcodeEncryptDecrypt;
|
|
134
134
|
const cryptFile = async (filePath, encryption, decrypt) => {
|
|
135
|
+
console.log("encryption cryptFile:>> ", encryption);
|
|
135
136
|
const data = await (0, file_1.processFileEncryptionDecryption)(filePath, encryption, decrypt);
|
|
136
137
|
return data;
|
|
137
138
|
};
|
package/build/utils/s3-util.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ interface S3Config {
|
|
|
12
12
|
append: boolean;
|
|
13
13
|
}
|
|
14
14
|
export declare const createS3Client: (awsConfig: AWSConfig) => S3Client | null;
|
|
15
|
-
export declare const fileUploadToS3: (files: any, s3Client: S3Client, s3Config: S3Config, publicS3Client: S3Client, publicS3Config: S3Config, isGenerateIcons: boolean, encryption: Encryption, options?: {}) => Promise<{
|
|
15
|
+
export declare const fileUploadToS3: (files: any, s3Client: S3Client, s3Config: S3Config, publicS3Client: S3Client, publicS3Config: S3Config, isGenerateIcons: boolean, encryption: Encryption, options?: {}, encrypted?: boolean) => Promise<{
|
|
16
16
|
originalname: any;
|
|
17
17
|
mimetype: any;
|
|
18
18
|
size: any;
|
package/build/utils/s3-util.js
CHANGED
|
@@ -31,8 +31,9 @@ const createS3Client = (awsConfig) => {
|
|
|
31
31
|
return s3client;
|
|
32
32
|
};
|
|
33
33
|
exports.createS3Client = createS3Client;
|
|
34
|
-
const fileUploadToS3 = async (files, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options = {}) => {
|
|
34
|
+
const fileUploadToS3 = async (files, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options = {}, encrypted = false) => {
|
|
35
35
|
if (Array.isArray(files)) {
|
|
36
|
+
console.log("Multiple file");
|
|
36
37
|
const fileOptions = [];
|
|
37
38
|
const s3Key = s3Config.key;
|
|
38
39
|
for (const file of files) {
|
|
@@ -40,7 +41,7 @@ const fileUploadToS3 = async (files, s3Client, s3Config, publicS3Client, publicS
|
|
|
40
41
|
if (s3Config.append) {
|
|
41
42
|
s3Config.key = `${s3Key}/${(0, uuid_1.v4)()}/${fileSlug}`;
|
|
42
43
|
}
|
|
43
|
-
const fileObj = await processFileUploadToS3(file, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options,
|
|
44
|
+
const fileObj = await processFileUploadToS3(file, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options, encrypted);
|
|
44
45
|
if (fileObj) {
|
|
45
46
|
fileOptions.push(fileObj);
|
|
46
47
|
}
|
|
@@ -48,17 +49,21 @@ const fileUploadToS3 = async (files, s3Client, s3Config, publicS3Client, publicS
|
|
|
48
49
|
return fileOptions;
|
|
49
50
|
}
|
|
50
51
|
else {
|
|
52
|
+
console.log("Single file");
|
|
51
53
|
const fileSlug = slugifyFileName(files.originalname);
|
|
52
54
|
if (s3Config.append) {
|
|
53
55
|
s3Config.key = `${s3Config.key}/${(0, uuid_1.v4)()}/${fileSlug}`;
|
|
54
56
|
}
|
|
55
|
-
|
|
57
|
+
console.log("encryption :>> ", encryption);
|
|
58
|
+
return await processFileUploadToS3(files, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options, encrypted);
|
|
56
59
|
}
|
|
57
60
|
};
|
|
58
61
|
exports.fileUploadToS3 = fileUploadToS3;
|
|
59
62
|
const processFileUploadToS3 = async (file, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options = {}, encrypt = false) => {
|
|
60
63
|
try {
|
|
64
|
+
console.log("encrypt :>> ", encrypt);
|
|
61
65
|
const contentType = mime_types_1.default.lookup(file.originalname) || "";
|
|
66
|
+
console.log("s3Config :>> ", s3Config);
|
|
62
67
|
const { acl, key, bucket } = s3Config;
|
|
63
68
|
let params = null;
|
|
64
69
|
let encryptedFilePath = null;
|
|
@@ -83,6 +88,8 @@ const processFileUploadToS3 = async (file, s3Client, s3Config, publicS3Client, p
|
|
|
83
88
|
...options,
|
|
84
89
|
};
|
|
85
90
|
}
|
|
91
|
+
console.log("encryptedFilePath :>> ", encryptedFilePath);
|
|
92
|
+
console.log("params :>> ", params);
|
|
86
93
|
const parallelUploads3 = new lib_storage_1.Upload({ client: s3Client, params });
|
|
87
94
|
const data = await parallelUploads3.done();
|
|
88
95
|
const { smallIcon, mediumIcon, largeIcon } = await handleIconUpload(file, contentType, publicS3Client, publicS3Config, isGenerateIcons, key, options);
|