AnsweredAssumed Answered

Can I cache file?

Question asked by srinijilla on May 18, 2017
Latest reply on Jan 29, 2018 by arun_thangavel
import java.util.*;
import java.util.regex.*;
import java.io.*;
import javax.activation.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.util.*;
import com.boomi.execution.ExecutionUtil;

for (int i = 0; i < dataContext.getDataCount(); i++) {
    InputStream is = dataContext.getStream(i);
    Properties props = dataContext.getProperties(i);
    logger = ExecutionUtil.getBaseLogger();
    DataSource ds = new ByteArrayDataSource(is, "multipart/form-data");
    MimeMultipart mmp = new MimeMultipart(ds);
    int cnt = mmp.getCount();
    for (int j = 0; j < cnt; j++) {
        MimeBodyPart mbp = mmp.getBodyPart(j);
        //FInd the form name
        String disp = mbp.getHeader("Content-Disposition", "");
        Pattern p = Pattern.compile("(\\sname=\")(.+?)(\")");
        Matcher m = p.matcher(disp);
        m.find();
        String name = m.group(2);
        try {
            switch (name) {
                case "EmpNo":
                    ExecutionUtil.setDynamicProcessProperty("DDP_EmpNo", mbp.getContent(), false);
                    break;

                case "Department":
                   
                    ExecutionUtil.setDynamicProcessProperty("DDP_DeptNo", mbp.getContent(), false);
                    break;
               

                case "Attachment":
                    dataContext.storeStream(mbp.getContentStream(), props);
                    break;
                default:
                    logger.info("" + name + ": Value -->" + mbp.getContent());

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Hi,

 

I am receiving form-data to my boomi process. One of the parameter is "File"

Thanks to the community, with your help I am able to successfully write the groovy script to read the form-data input values.

 

Now the challenge we are facing, we want to use this file(which we received in input) later to send to another http client connector.

1) Can I store this file on cache? Or as the name suggests, "Document Cache" can only cache documents and not files? 

2) How can I hold file for later in the process? (Except writing to Disk  )

 

Appreciate any little help.

 

Thanks,

Srini

Outcomes