Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
convertImgToBlob(`https://www.thetvdb.com/banners/${res.filename}`).then(blob => {
db.insert({
_id: `img${tvelem.show.replace(' ', '')}S${tvelem.season}E${tvelem.episode}`,
elempath: data[2],
elem: data[0],
tvelem: data[1],
imgData: blob
});
blobUtil.base64StringToBlob(blob, 'image/jpeg').then(blob => {
console.info(blob);
img.children[0].style.backgroundImage = `url(${URL.createObjectURL(blob)})`; // eslint-disable-line
}).catch(err => {
Raven.captureException(err);
Raven.showReportDialog();
});
});
} else if (res.filename === '') {
db.find({_id: `img${tvelem.show.replace(' ', '')}S${tvelem.season}E${tvelem.episode}`}, (err, doc) => {
if (err) {
Raven.captureException(err);
Raven.showReportDialog();
}
blobUtil.base64StringToBlob(doc[0].imgData, 'image/jpeg').then(blob => {
img.children[0].style.backgroundImage = `url(${URL.createObjectURL(blob)})`; // eslint-disable-line
resolve(['got from db']);
}).catch(err => {
Raven.captureException(err);
Raven.showReportDialog();
});
});
}
it('convertToBlob() works as expected', async () => {
const config = { blob: base64 }
expect(await convertToBlob(config)).toEqual({
blob: await blobUtil.base64StringToBlob(config.blob)
})
expect(convertToBlob({})).toEqual({})
})
})
export function convertToBlob (config) {
if (isBlobbable(config.blob) || !isBase64(config.blob)) {
return config
}
return Object.assign({}, config, {
blob: blobUtil.base64StringToBlob(config.blob)
})
}
function showAddBtTaskWithFile (fileName, base64Data = '') {
const blob = base64StringToBlob(base64Data, 'application/x-bittorrent')
const file = new File([blob], fileName, { type: 'application/x-bittorrent' })
const fileList = buildFileList(file)
store.dispatch('app/showAddTaskDialog', 'torrent')
setTimeout(() => {
store.dispatch('app/addTaskAddTorrents', { fileList })
}, 200)
}
function showAddBtTaskWithFile (fileName, base64Data = '') {
const blob = base64StringToBlob(base64Data, 'application/x-bittorrent')
const file = new File([blob], fileName, { type: 'application/x-bittorrent' })
const fileList = buildFileList(file)
store.dispatch('app/showAddTaskDialog', 'torrent')
setTimeout(() => {
store.dispatch('app/addTaskAddTorrents', { fileList })
}, 200)
}