That title will not do this question justice.
I have an application that uses the filepicker. The onFileSelected trigger calls a function uploadImage, which is supposed to generate a uuid via https://unpkg.com/[email protected]/dist/umd/uuidv4.min.js, and insert the image into an S3 bucket. This was all working fine before the most recent release of v1.8.5.
Now, however, the function executes fine on the first run, but if you want to upload another image using the same function, it throws an error: "Uncaught Promise Rejection: uuidv4 is not defined".
Why would it suddenly stop working? Was there something in 1.8.5 that might have broken this admittedly janky implementation?
The function:
uploadImage: async function(fileInput, query) {
// If no fileInput is defined it's likely that this function
// has been call by appsmith to determine if it is async.
// This call should be ignored
if (!fileInput) return null;
if (fileInput.files.length !== 1) {
throw new Error("Error: More than one image passed to file uploader")
return null;
}
if(typeof uuidv4 !== 'function') {
await import("https://unpkg.com/[email protected]/dist/umd/uuidv4.min.js");
}
const file = fileInput.files[0];
const extension = file.name.split('.').pop();
const id = uuidv4();
const name = `${id}.${extension}`;
await query.run({ name, file });
}