Hi, I am trying to create a thumbnail of an uploaded image using cloud code (from https://community.parseplatform.org/t/image-thumbnails/160/2).
The code below works fine until the last line thumbfile.save(null, { useMasterKey: true })
for which I get the error ParseError: unauthorized at handleError (/home/parse/node_modules/parse/lib/node/RESTController.js:422:17)
.
Why does it give this error even when I use the master key?
And if I try to set an ACL to thumbfile
I get the error TypeError: node.setACL is not a function
Any help on how to fix this or what the problem is? Thanks
In Parse.Cloud.afterSaveFile:
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 });
//setDenyWriteACL(thumbfile);
await thumbfile.save(null, { useMasterKey: true });
}