{DEBUG} Get images

This commit is contained in:
Damien Broqua 2023-09-18 14:31:51 +02:00
parent 2f988798df
commit fd0a9df724
3 changed files with 13 additions and 7 deletions

View file

@ -62,11 +62,15 @@ export const uploadFromUrl = async (url) => {
const filename = `${uuid()}.jpg`;
const file = `/tmp/${filename}`;
const { data } = await axios.get(url, { responseType: "arraybuffer" });
const { data } = await axios.get(url, {
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.0",
},
responseType: "arraybuffer",
});
fs.writeFileSync(file, data);
return uploadFromFile(filename, file, true);
// return s3Object;
};

View file

@ -43,6 +43,9 @@ class Albums extends Pages {
model: "Albums",
id: album._id,
};
const job = new JobsModel(jobData);
job.save();
try {
const User = await UsersModel.findOne({ _id: user._id });
@ -110,11 +113,8 @@ Publié automatiquement via #musictopus`;
await M.post("statuses", { status, media_ids });
}
const job = new JobsModel(jobData);
job.save();
} catch (err) {
console.log("Err:", err);
throw new ErrorEvent(
500,
"Mastodon",

View file

@ -99,6 +99,8 @@ class Jobs {
await job.save();
console.log("ERR:", err);
throw err;
}
}