How i can move a file that has been attached with widget?

1
0
-1

Hi,

I want to move a file to another folderThis file will be attached with a widget.

Now i have created a script task, and i have impelemented this code, but when i try to test, nothing works good.Here is the java code:

` import org.bonitasoft.engine.bpm.document.Document;
import org.bonitasoft.engine.bpm.document.DocumentValue;

Document doc=apiAccessor.getProcessAPI().getLastDocument(processInstanceId, "attachedDoc").getId();
//Document doc=apiAccessor.getProcessAPI().getDocument(attachedDoc);
DocumentValue docValue=new DocumentValue(apiAccessor.getProcessAPI().getDocumentContent(doc.getContentStorageId()), doc.getContentMimeType(), doc.getContentFileName());
return docValue;

`

Regards

Comments

Submitted by Sean McP on Tue, 07/19/2016 - 04:28

A small hint here. Don't use the "code" buttons from Bonita (as above) they don't work as you can see,

Start code blocks with < code > and end with < /code > removing the spaces and it will format the code correctly

regards
Seán

Submitted by Sean McP on Tue, 07/19/2016 - 04:35

Nothing works good is not a good question.

What is Nothing works good ?

Where are the logs to say what is wrong?

What is it you are trying to do?

I want to move a file to another folder. This file will be attached with a widget.

It's not really clear, can you give an example? For example -

I need to move file driveC://thisFile.txt to driveD://thisDir/thisFile.txt

Try to be a bit clearer and the answers will be easier to calculate.

regards
Seán

Submitted by claz08 on Tue, 07/19/2016 - 15:58

Ok , i will explain ..

I have created a form that contains a simple widget that allow to upload a file. Acording the bonita behavior, this file is converted to a binary file and afterwards is stored to bonita database. Now i have created an external PHP code that permit me to move this file to another directory(for example:c:/new_directory), but what i'm looking for is to move it through java code into workflow without using any external script like PHP, javascript..and so on.

I hope that you understand me.

Submitted by Sean McP on Tue, 07/19/2016 - 22:15

You want to move the document from task to task, from process to process?

Don't move the document, just send the documentId. That's all you need the id of the document where you need it.

For task to task in the same process is even easier, define your document at the process level (it's the only place you can define it), and it is available to ALL tasks in the same process.

Is this what you are looking for?

regards

Submitted by claz08 on Tue, 07/19/2016 - 22:25

No, because i need to move|copy The attached file to a simple folder on The disk.

Submitted by claz08 on Tue, 07/19/2016 - 22:25

No, because i need to move|copy The attached file to a simple folder on The disk.

3 answers

1
0
-1

The quality of sound amongst those two types of headphones is small so pick what fits into your budget.

Read more here BestHeadphonesUnder100.net

1
0
-1

People who make use of the ADSL router these days get more benefits than users of ADSL modem. This is because all routers IP like 192.168.2.1 in this category at this time have built-in basic firewalling elements.

1
0
-1

This is what you need:

But you'll have to code it correctly as it's not from Bonita...

byte[] buffer = new byte[8 * 1024];

//Set output filename
String filename = "D:/mydir/myfile.txt"

//set input stream
InputStream input = urlConnect.getInputStream();
try {
  OutputStream output = new FileOutputStream(filename);
  try {
    int bytesRead;
    while ((bytesRead = input.read(buffer)) != -1) {
      output.write(buffer, 0, bytesRead);
    }
  } finally {
    output.close();
  }
} finally {
  input.close();
}

regards
Seán

PS: If this reply answers your question, please mark as resolved.

Notifications