kalai-attach 1.0.6 → 1.0.8
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/package.json +1 -1
- package/srv/azure-blob-storage.js +1 -24
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kalai-attach",
|
|
3
3
|
"description": "CAP cds-plugin providing image and attachment storing out-of-the-box.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"repository": "capjsattachments-kalai",
|
|
6
6
|
"author": "Kalai",
|
|
7
7
|
"homepage": "https://github.com/Kalaikovan-airdit",
|
|
@@ -12,7 +12,6 @@ module.exports = class AzureAttachmentsService extends require("./object-store")
|
|
|
12
12
|
async retrieveClient() {
|
|
13
13
|
try{
|
|
14
14
|
const container_name="aisp"
|
|
15
|
-
console.log("khbdchdcbjdcc")
|
|
16
15
|
const sas_token="sp=rcwdl&st=2025-12-26T10:41:33Z&se=2030-12-25T18:56:33Z&spr=https&sv=2024-11-04&sr=c&sig=i5ENp1nzh0GrnNd%2FCAnkBBK3vCrHI8vCnHS9og%2F8P8I%3D"
|
|
17
16
|
const container_uri="https://aairdoc9262.blob.core.windows.net"
|
|
18
17
|
|
|
@@ -110,29 +109,7 @@ module.exports = class AzureAttachmentsService extends require("./object-store")
|
|
|
110
109
|
|
|
111
110
|
// The file upload has to be done first, so super.put can compute the hash and trigger malware scan
|
|
112
111
|
await blobClient.upload(_content, contentLength)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const { content, ...metadata } = data;
|
|
117
|
-
const blobName = metadata.url || metadata.ID;
|
|
118
|
-
const blobClient = containerClient.getBlockBlobClient(blobName);
|
|
119
|
-
|
|
120
|
-
// 1. Upload to Azure first (Staging)
|
|
121
|
-
await blobClient.upload(content, content.length);
|
|
122
|
-
|
|
123
|
-
// 2. Call super.put - This triggers the malware scan
|
|
124
|
-
// If the scanner finds a virus, this call will THROW an error
|
|
125
|
-
await super.put(attachments, data);
|
|
126
|
-
|
|
127
|
-
LOG.info(`Scan passed and file uploaded: ${metadata.filename}`);
|
|
128
|
-
} catch (err) {
|
|
129
|
-
// 3. If scan fails (or any other error), clean up Azure
|
|
130
|
-
if (err.code === 403 || err.message.includes('malware')) {
|
|
131
|
-
LOG.error(`Malware detected in ${data.filename}! Deleting from Azure...`);
|
|
132
|
-
await this.delete(data.url || data.ID);
|
|
133
|
-
}
|
|
134
|
-
throw err;
|
|
135
|
-
}
|
|
112
|
+
await super.put(attachments, metadata)
|
|
136
113
|
|
|
137
114
|
const duration = Date.now() - startTime
|
|
138
115
|
LOG.debug('File upload to Azure Blob Storage completed successfully', {
|