Thanks for the help, I moved everything into Job and changed what you wrote:
Parse.Cloud.job("createThumb", async (request) => {
const { params, headers, log, message } = request;
message("I just started");
const file = params.f;
const fileName = file.name();
const fileData = await file.getData();
const fileBuffer = Buffer.from(fileData, 'base64');
const mimeInfo = await fileType.fromBuffer(fileBuffer);
if (mimeInfo.mime.startsWith("image")) {
const options = { percentage: 5, responseType: 'base64' };
const thumbnail = await imageThumbnail(fileBuffer, options);
const thumbfile = new Parse.File("thumb_" + fileName, { base64: thumbnail });
try {
await thumbfile.save({ useMasterKey: true });
} catch (err) {
console.log("Failed to save thumb; " + err);
return false;
}
}
message("I just finished");
return true;
});
However it gets an error when saving the file: Failed to save thumb; ParseError: 130 Unauthorised!