Nikita Petrov
04/04/2019, 2:45 PMwhile (chunk = file.getReader().readChars(1000)) { postBody += chunk }
and it even works, but I don't know what to do next to get a normal base64 encoded jpeg file from this 'postBody' variable. Is it possible at all?
This variable looks like '����JFIF��C' when I try to output it in the browser.
It looks like the current 'postBody' variable is encoded somehow too, maybe it is a hex representation of the binary file, I don't know.
Do you have any ideas how to send a binary file which is larger 10Mb from Netsuite file cabinet via http POST request?
Thanks.Wolf
04/04/2019, 3:09 PMWolf
04/04/2019, 3:10 PMNikita Petrov
04/04/2019, 3:20 PMWolf
04/04/2019, 3:24 PMNikita Petrov
04/04/2019, 3:29 PMWolf
04/04/2019, 3:30 PMNikita Petrov
04/04/2019, 3:31 PMNikita Petrov
04/05/2019, 6:07 AMvar hexEncodedString = ''
var reader = netsuiteFile.getReader()
var chunk;
while(chunk = reader.readChars(1000)) {
hexEncodedString += chunk
}
payload = encode.convert({
string: hexEncodedString,
//inputEncoding: encode.Encoding.HEX,
inputEncoding: encode.Encoding.UTF_8,
outputEncoding: encode.Encoding.BASE_64
});
Nikita Petrov
04/05/2019, 7:14 AMNikita Petrov
04/05/2019, 7:19 AMvar netsuiteFile = context.request.files['uploadfileformfield']
var hexEncodedString = ''
var reader = netsuiteFile.getReader()
var chunk
while(chunk = reader.readChars(1000)) {
hexEncodedString += chunk
}
var Newfile = file.create({
name: 'test-after.jpg',
fileType: file.Type.PLAINTEXT,
contents: hexEncodedString,
encoding: file.Encoding.UTF_8,
folder: 30,
}).save()
The filesize is twice bigger then the original file.Nikita Petrov
04/05/2019, 7:23 AMvar Newfile = file.create({
name: 'test-after.jpg',
fileType: file.Type.JPGIMAGE,
contents: hexEncodedString,
folder: 30,
}).save()
So I assume reader.readChars converts my binary to a plaintext string and it is impossible to get a normal binary representation of it, isn't it?Wolf
04/05/2019, 5:27 PMWolf
04/05/2019, 5:27 PM