I've asked the question previously and got many an...
# suitescript
s
I've asked the question previously and got many answers, thanks for everyone, but, clearly, I'm doing something wrong. I have a script that receive an image, and save it like this: ----------------------------------------------------------------------------------------------------------------- if (fileContents.indexOf('data:image/jpeg;base64') != -1) fileContents = fileContents.substring('data:image/jpeg;base64,'.length, fileContents.length); var fileObj = file.create({ name: fileName, fileType: file.Type.JPGIMAGE, contents: fileContents, folder: folderID }); var fileId = fileObj.save(); -------------------------------------------------------------------------------------------------------------------- I also save the fileId. This part works very well. Then later, I have another script that send the image back. That's where my problem is. How can I reconvert the image to base64 ? Or I maybe all wrong, what else do I need to do ? Thanks in advance
c
What do you mean by "send the image back"? You want to serve it via HTTP/HTTPS?
s
@Simon if you want the image file from filecabinet in base64, and its a jpg, I could be wrong, but I think if you do
Copy code
var fileObj = file.load(...);
var base64Content = fileObj.getContents();
this is what I'd try??
s
@Sciuridae54696d it makes sense. I'm trying it
👍 1
Thanks guys, I found my problem 🙂
🙌 1
n
What was the problem? @Simon
s
My fault. I'm taking over this project. I did not look at the custom record, I expected that the field where the id is saved was an ID, not an image. Well the previous developer had set the field to image. I created a new ID field, save the fileid in it and everything is fine.
👍 2