mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2025-02-17 03:48:25 +00:00
#507 WIP
This commit is contained in:
parent
ddd845d9d1
commit
0f930f6257
2 changed files with 15 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
'use strict'
|
||||
import { app, protocol, BrowserWindow, Menu} from 'electron';
|
||||
import { wtutils } from '../src/components/modules/General/wtutils';
|
||||
import axios from 'axios';
|
||||
|
||||
const log = require('electron-log');
|
||||
console.log = log.log;
|
||||
|
@ -115,8 +116,8 @@ if (isDevelopment) {
|
|||
}
|
||||
}
|
||||
|
||||
const axios = require('axios')
|
||||
const fs = require('fs')
|
||||
//const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
|
||||
ipcMain.on('downloadFile', function (event, data) {
|
||||
const filePath = data.filePath;
|
||||
|
@ -153,14 +154,21 @@ ipcMain.on('downloadMedia', function (event, data) {
|
|||
const agent = new https.Agent({
|
||||
rejectUnauthorized: false
|
||||
});
|
||||
|
||||
filePath, item, agent
|
||||
|
||||
console.log('Ged 12-3 background download start')
|
||||
console.log('Ged 12-4', JSON.stringify(data))
|
||||
|
||||
|
||||
axios({
|
||||
method: 'GET',
|
||||
url: item,
|
||||
url: data.url,
|
||||
headers: data.header,
|
||||
responseType: 'stream',
|
||||
httpsAgent: agent
|
||||
}).then((response) => {
|
||||
response.data.pipe(fs.createWriteStream(filePath))
|
||||
response.data.pipe(fs.createWriteStream(data.targetFile))
|
||||
response.data.on('end', () => {
|
||||
event.sender.send('downloadMediaEnd');
|
||||
})
|
||||
|
|
|
@ -100,6 +100,7 @@ const download = new class DOWNLOAD {
|
|||
}
|
||||
console.log('Ged 1-3-5')
|
||||
header['Content-Range'] = rangeStart;
|
||||
header['Accept'] = '*/*';
|
||||
// Url to download
|
||||
const url = this.item.baseAddress + this.item.key + '?download=1';
|
||||
|
||||
|
@ -122,8 +123,8 @@ const download = new class DOWNLOAD {
|
|||
{
|
||||
_this.isDownloading = true;
|
||||
ipcRenderer.send('downloadMedia', {
|
||||
item: url,
|
||||
filePath: this.item.targetFile,
|
||||
url: url,
|
||||
targetFile: this.item.targetFile,
|
||||
header: header
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue