Rank 2: Process
I'm using this function to get the preview of the document/images for displaying it on frontend
export async function fetchNotesForPreview(fileId: string) {
try {
const result = await storage.getFilePreview(
BUCKET_ID!, // bucketId
fileId, // fileId
100, // width (optional)
100, // height (optional)
ImageGravity.Center, // gravity (optional)
100, // quality (optional)
0, // borderWidth (optional)
'#000000', // borderColor (optional) - Use a valid hex color code
0, // borderRadius (optional)
1, // opacity (optional)
0, // rotation (optional)
'', // background (optional)
ImageFormat.Jpg // output (optional)
);
// Convert the Buffer to a Base64 URL
const base64Data = result.toString();
const previewUrl = `data:image/jpeg;base64,${base64Data}`;
console.log(previewUrl);
return previewUrl;
} catch (error) {
console.log('Error fetching notes-files for preview', error);
return ''; // Return an empty string or a fallback image URL
}
}
BUT it's giving me the above error
how do I get rid of it
also do u have proper docs for preview file?