//threshold = lm.getRuntimeThreshold(threshold);
if (length >= threshold && attachmentDir != null) {
// Get the file accessor
FileAccessor fileAccessor = lm.create(attachmentDir);
OutputStream fos = fileAccessor.getOutputStream();
//Copy the bytes into the file
ByteArrayInputStream is = new ByteArrayInputStream(b, off, length);
BufferUtils.inputStream2OutputStream(is, fos);