Save Attachment File in a disk

1
0
-1

Hello, I need to save attachments that are loaded into the process on the hard drive of the computer. Someone can help me?

Thank you

Greetings.

Comments

Submitted by francois.chevresson on Tue, 06/10/2014 - 22:53

Hi,

Which version of Bonita are you using?

Submitted by ale.ghirardi on Tue, 06/10/2014 - 23:11

Bonita BPM 6.3 comunity version

3 answers

1
0
-1

Hi,

Here is a version developed using 6.3.1. http://we.tl/Tvvnhyk8sN

I hope it helps :)

Comments

Submitted by ale.ghirardi on Tue, 06/24/2014 - 23:44

The file is saved correctly, but I need to continue appearing in other forms to download

Submitted by francois.chevresson on Tue, 06/24/2014 - 23:58

in that case return the name of the document from the groovy script instead of a boolean and assign the result of the operation to a Document variable in bonita.

Submitted by ale.ghirardi on Wed, 06/25/2014 - 00:03

Thank You very much!!!

Regards!

Submitted by francois.chevresson on Wed, 06/25/2014 - 00:56

You're welcome :)

1
0
-1

I feel the same as a kkpatel. And when I run the process after having created the groovy connector with the code I do not save the attachment

Comments

Submitted by Giro1981 on Sun, 06/29/2014 - 20:43

Please, could you share this example again?

I tried to download it but it doesn't seems to be available yet..

Submitted by francois.chevresson on Mon, 06/30/2014 - 21:59
Submitted by Giro1981 on Mon, 06/30/2014 - 23:54

Many thanks!

Submitted by Giro1981 on Tue, 07/01/2014 - 09:49

Hi François,

If I'm not wrong in this example file is saved in disk getting content directly from form field: fos.write(field_File1.getContent());

But, what could I do if I want get contet from internal document associated with case? I have an acitivity at the end of the process that it should save in disk all documents attached during the process in previous tasks.

Could you help me about which api class I have to use to do that?

Thanks in advance,

Submitted by francois.chevresson on Wed, 07/02/2014 - 21:42

Hi,

You can retrieve all the documents attached to the process instance using the processApi method: http://documentation.bonitasoft.com/javadoc/api/6.0/sp/common/org/bonita...(long, int, int, org.bonitasoft.engine.bpm.document.DocumentCriterion)

From the document, you can get the storageId use to retrieve the content using getDocumentContent

Submitted by Giro1981 on Thu, 07/03/2014 - 10:11

Thanks, I'll try it, but do you know what values have to be set in fields "int pageIndex, int numberPerPage"?

API describes them as: pageIndex - The index of the page numberPerPage - The number of documents to list per page

but I'm not quite sure that it means.

Thanks for your help,

1
0
-1

An easy way would be to add a script saving your file from the output operation of the file widget:

try
{
 FileOutputStream fos = new FileOutputStream("c:\\temp\\storeThis.text");
  fos.write(field_File1.getContent());
  fos.close();
}
catch(FileNotFoundException ex)
{
 System.out.println("FileNotFoundException : " + ex);
}
catch(IOException ioe)
{
 System.out.println("IOException : " + ioe);
}

I'm attaching an example. http://we.tl/wKIsY6isLm

Comments

Submitted by kppatel on Mon, 06/16/2014 - 20:26

Hello i m using also 6.3 community . when i try to import process it give : Incompatible version error . what should i do ?

i have same issue and i really need it thanks

Submitted by kppatel on Mon, 06/16/2014 - 20:35

Pl look following screenshot :

f

error as follow :

eror

Submitted by ale.ghirardi on Thu, 06/19/2014 - 17:00

Please copy the Bonita Engine log to see the error must

Submitted by danilo.martino on Thu, 08/28/2014 - 15:51

Hello I am using Bonita Community Edition v. 6.3.

How can I retry a document saved on hard drive by the groovy script posted above by francois.chevresson?

Carry the code below:

try
{
FileOutputStream fos = new FileOutputStream("c:\\temp\\storeThis.text");
fos.write(field_File1.getContent());
fos.close();
}
catch(FileNotFoundException ex)
{
System.out.println("FileNotFoundException : " + ex);
}
catch(IOException ioe)
{
System.out.println("IOException : " + ioe);
}

I have configured a form in which I created an input field; in the Data section I have setted these Data Decriptions: - 'download only' clicked - 'initial value' setted to 'Document';

Although this configuration, I don't found - in Client Portal - link to retry original document saved on hard drive.

For completeness I show you the groovy script used to retry document link:

String path = "correct_path" +variable_storing_field_File1.getFileName();
return path;

@francois.chevresson Please, could you share this example again?

Thank you for all.

Best regards.

Submitted by sam87 on Sat, 01/03/2015 - 06:15

@francois.chevresson Please, could you share this example again?

I tried to download it but it doesn't seems to be available yet..

Best regards.

Submitted by claz08 on Tue, 07/19/2016 - 17:49

hi , i really need this example , please if there anyone that have this example , plese share it!

Notifications