web stats
file content truncated - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-20-2016, 01:07 AM
Colizobble Colizobble is offline
OBX.1 Kenobi
 
Join Date: Mar 2008
Posts: 33
Colizobble
Default file content truncated

I have a database reader channel + file reader transformer => file writer destinations.
I read various contents and file names from the database, including the source path and output filename of a pdf.
In the source transformer, I'm reading the contents of the pdf from the file system to add to the channel map.

The test pdf I'm using is about 700k. The javascript code below is the transformer step.

The FileUtil.readBytes method seems to successfully read the whole file, as the logger records the correct length of the byte array. However the output variable is only 6 bytes long and this is what is being written by the file writer (binary mode).

Is there something I'm missing? I've attached the channel definition.
Thanks

Code:
var mapping;

try {
	if (msg['sourcepathpdf'].toString()!='') {
		mapping = FileUtil.readBytes(msg['sourcepathpdf'].toString());
		logger.info('File length: '+mapping.length);
	}
}
catch(e) {
	logger.error(e);
	mapping = '';
}

channelMap.put('contentPdf', mapping);
Attached Files
File Type: xml HilisGel data export.xml (73.9 KB, 0 views)

Last edited by Colizobble; 02-20-2016 at 01:09 AM.
Reply With Quote
  #2  
Old 02-20-2016, 02:36 AM
Colizobble Colizobble is offline
OBX.1 Kenobi
 
Join Date: Mar 2008
Posts: 33
Colizobble
Default

I've found the answer myself.
I just needed to encode the binary array before putting the content on the channel map:

Code:
var mapping;

try {
	if (msg['sourcepathpdf'].toString()!='') {
		var content = FileUtil.readBytes(msg['sourcepathpdf'].toString());
		mapping=FileUtil.encode(content);
	}
}
catch(e) {
	logger.error(e);
	mapping = '';
}

channelMap.put('contentPdf', mapping);
Reply With Quote
Reply

Tags
readbytes length

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:18 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation