How to Convert DocumentValue into File (DataType) in Groovy Script
In Continue i resolved it.
`import org.apache.http.HttpResponse
import org.apache.http.client.HttpClient
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.mime.MultipartEntity
import org.apache.http.entity.mime.content.FileBody
import org.apache.http.entity.mime.content.StringBody
import org.apache.http.impl.client.HttpClientBuilder
import org.bonitasoft.engine.bpm.document.DocumentValue
import org.bonitasoft.engine.io.IOUtil
@SuppressWarnings("deprecation")
// create HTTP Client
def dump = 'Sucess';
MultipartEntity entity = new MultipartEntity();
byte[] content = apiAccessor.getProcessAPI().getDocumentContent(personPic.getId().toString())
String fileName = personPic.getName()
File personPicFile = File.createTempFile("tmp", fileName);
IOUtil.write(personPicFile, content);
entity.addPart("picture", new FileBody(personPicFile));
personPicFile.delete();
return dump;`
If any other way can help please, share it.
Thanks,
Ali
Comments
Hello
Have you tried FileOutputStream. I use outputstream classes to generate any file type i want. Just pass the correct mime type.
Regards
Hi Roy,
In this case i use FileOutputStream :
But in above case i have DocumentValue and need Convert into File.
Thanks.
Ali
Thanks for sharing the code.
I hope that anyone else having similar issues will benefit from it.
Thanks
can you please tell how to add jar file of http.entity.mime in bonita studio?