vtb-appit 0.0.59 → 0.0.60
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/appit-base-transformer.js +26 -22
- package/package.json +1 -1
|
@@ -242,28 +242,32 @@ class AppitBaseTransformer {
|
|
|
242
242
|
|
|
243
243
|
promises.push(new Promise((resolve, reject) => {
|
|
244
244
|
for(let i = 0; i < media.length; i++) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
245
|
+
try {
|
|
246
|
+
const req = https.request(media[i].url, res => {
|
|
247
|
+
let chunks = [];
|
|
248
|
+
res.on('data', chunk => {
|
|
249
|
+
chunks.push(chunk);
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
res.on('end', () => {
|
|
253
|
+
const buffer = Buffer.concat(chunks).toString('base64');
|
|
254
|
+
let base64Data = 'data:' + res.headers['content-type'] + ';base64,';
|
|
255
|
+
base64Data += buffer;
|
|
256
|
+
|
|
257
|
+
let frags = media[i].url.split('/');
|
|
258
|
+
|
|
259
|
+
resolve({
|
|
260
|
+
title: '',
|
|
261
|
+
name: frags[frags.length - 1],
|
|
262
|
+
content: base64Data
|
|
263
|
+
});
|
|
264
|
+
})
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
req.end();
|
|
268
|
+
} catch(e) {
|
|
269
|
+
resolve({});
|
|
270
|
+
}
|
|
267
271
|
}
|
|
268
272
|
}));
|
|
269
273
|
|