So I have a collection called Bulletins the collection has a column for PDFs called BulletinPDF and a column for images called BulletinJPG. I have a form where allow the user to create a new the collection. It includes picking a date then selecting a PDF and a JPG to upload. The jpg is just the same as the PDF but I need it for previewing thumbnail purposes. I want to use the convertapi node module to convert the PDF to the jpg automatically so the user only has to upload a single file and wix code will convert the rest.
This is as far as I got:
import {convertapiPackage} from ‘backend/convertapi’;
const convertapi = convertapiPackage(‘secreterasedhere’);
export function Bulletin_beforeInsert(item, context) {
item.title = (item.sunday.toString()).slice(4, 15);
//convert pdf to jpg
convertapi.convert(‘jpg’, {
File: ‘/path/to/my_file.pdf’,
JpgQuality: ‘100’
}, ‘pdf’).then( function (result) {
result.saveFiles(‘/path/to/dir’);
});
return item;
The issue is I don’t know where the file actually sits and where to export the converted image to for this to work. So I need a way to pass file-paths in if possible. Any pointers or help are appreciated.