NetSuite does convert Base64 image data to a JPEG file in the file cabinet automatically. I have tried different methods to decode the base 64 encoded image data. Failed to save the image data to a folder created in file cabinet.
solution: Use N/encode module, in file.create() use “file.Encoding.BASE_64” for encoding type. Instead of trying this i have ignored this encoding type. After using this method the image file successfully saved to file cabinet.
let fileObj = file.create({
name: 'testWorld.jpg',
fileType: fileObj1.fileType,
contents: imageFileContent1,
encoding: file.Encoding.BASE_64,
folder: 757,
isOnline: true
});
let fileId = fileObj.save();
To save base 64 encoded PDF file to file cabinet, no need to use
"encoding: file.Encoding.BASE_64" , Netsuite directly save the file content to file cabinet.
let imageFileContent1 = fileObj1.getContents();
let fileObj = file.create({
name: 'pdfnew.pdf',
fileType: fileObj1.fileType,
contents: imageFileContent1,
folder: 757,
isOnline: true
});