Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Attachment Handler does not accomodate more than 40 characters for mime type #4479

Open
snceaston opened this issue Mar 17, 2021 · 0 comments
Labels
bug Something isn't working Internal-Issue-Created An issue has been created in NextGen's internal issue tracker RS-6042 triaged

Comments

@snceaston
Copy link

Describe the bug
Using a javascript attachment handler to record the mime type as "application/vnd.openxmlformats-officedocument.wordprocessingml.document" for a docx file causes the following issue:

org.postgresql.util.PSQLException: ERROR: value too long for type character varying(40)
at com.mirth.connect.donkey.server.data.jdbc.JdbcDao.insertMessageAttachment(JdbcDao.java:547)

To Reproduce
This is the current content of the javascript attachment handler:

// Modify the message variable below to create attachments
var filename = ''+$('originalFilename');
if (filename != '') {
	var extension = (filename.substring(filename.lastIndexOf('.')+1, filename.length) || filename).toLowerCase();
	// work our mime type from extension
	switch (extension) {
		case 'pdf': 
			mimetype = 'application/pdf';
			break;
		case 'doc':
			mimetype = 'application/msword';
			break;
		case 'docx':
			mimetype = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
			break;
		case 'gif':
			mimetype = 'image/gif';
			break;
		case 'jpg':
			mimetype = 'image/jpeg';
			break;
		case 'tif':
			mimetype = 'image/tiff';
			break;
		case 'png':
			mimetype = 'image/png';
			break;
		case 'rtf':
			mimetype = 'application/rtf';
			break;
		case 'txt':
			mimetype = 'text/plain';
			break;
		case 'html':
			mimetype = 'text/html';
			break;	
		case 'mht':
			mimetype = 'multipart/related';
			break;
		default: 
			mimetype = '';
	}
}
var attachment = addAttachment(message.toString().replace(/[\r\n]/g,''), mimetype);
var attachmentToken = attachment.getAttachmentId();
return attachmentToken;

Environment (please complete the following information):

  • OS: Linux (CentOS)
  • Java 1.8.0_171
  • Connect Version 3.10.0

Workaround(s)
-- don't save the correct mime type?

@snceaston snceaston added the bug Something isn't working label Mar 17, 2021
@cturczynskyj cturczynskyj added Internal-Issue-Created An issue has been created in NextGen's internal issue tracker RS-6042 triaged labels Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Internal-Issue-Created An issue has been created in NextGen's internal issue tracker RS-6042 triaged
Projects
None yet
Development

No branches or pull requests

2 participants