You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
558 B
JavaScript
18 lines
558 B
JavaScript
3 years ago
|
const axios = require('axios');
|
||
|
const db = require('../../db');
|
||
|
|
||
|
module.exports = async function(db, itemImages, adminUUID) {
|
||
|
for (const item of itemImages) {
|
||
|
const {uuid, name, images} = item;
|
||
|
|
||
|
console.log(` Downloading images for item: ${name}`)
|
||
|
|
||
|
for (const imageName of images) {
|
||
|
const url = `https://societyofsocks.us/media/${imageName}`
|
||
|
console.log(' Downloading ' + url)
|
||
|
const response = await axios.get(url, { responseType: 'arraybuffer' })
|
||
|
|
||
|
await db.item.addImage(uuid, response.data, adminUUID);
|
||
|
}
|
||
|
}
|
||
|
}
|