node-red-contrib-hik-media-buffer 1.2.7 → 1.2.9

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.
Files changed (2) hide show
  1. package/hik-download.js +12 -2
  2. package/package.json +1 -1
package/hik-download.js CHANGED
@@ -100,7 +100,7 @@ module.exports = function(RED) {
100
100
 
101
101
  // Creazione cartella di salvataggio C:\download\YYYY-MM-DD
102
102
  const dataGiorno = startTimeRaw.substring(0, 10).replace(/\//g, '-');
103
- const baseDir = "C:\\download";
103
+ const baseDir = process.platform === "win32" ? "C:\\download" : "/home/allsystem/download";
104
104
  const targetDir = path.join(baseDir, dataGiorno);
105
105
 
106
106
  try {
@@ -162,6 +162,13 @@ module.exports = function(RED) {
162
162
  const finalFilePath = path.join(targetDir, finalFileName);
163
163
 
164
164
  const writer = fs.createWriteStream(finalFilePath);
165
+ const videoChunks = [];
166
+
167
+ // Ascoltiamo i dati in arrivo dallo stream per salvarli anche in memoria
168
+ response.data.on('data', (chunk) => {
169
+ videoChunks.push(chunk);
170
+ });
171
+
165
172
  response.data.pipe(writer);
166
173
 
167
174
  await new Promise((resolve, reject) => {
@@ -174,8 +181,11 @@ module.exports = function(RED) {
174
181
 
175
182
  node.log(`File salvato in: ${finalFilePath}`);
176
183
 
184
+ const videoBuffer = Buffer.concat(videoChunks);
185
+
177
186
  let outMsg = RED.util.cloneMessage(msg);
178
- outMsg.payload = finalFilePath;
187
+ outMsg.payload = videoBuffer;
188
+ outMsg.localFilePath = finalFilePath;
179
189
  outMsg.channel = ch;
180
190
  outMsg.filename = finalFileName;
181
191
  node.send(outMsg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-hik-media-buffer",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "Ottiene buffer video e immagine da camere Hikvision via ISAPI",
5
5
  "keywords": [
6
6
  "node-red",