cancel
Showing results for 
Search instead for 
Did you mean: 

Attached file content issue

saurabh_gotharw
Champ in-the-making
Champ in-the-making

I attached a file with a task and fetched its content using 

runtime/tasks/{taskId}/attachment/{attachmentId}/content

api. I am able to save content of text file successfully but for other formats data is not getting saved properly and saved files are getting corrupted.

6 REPLIES 6

gdharley
Elite Collaborator
Elite Collaborator

Please provide more detail and a unit test. Otherwise there is not much anyone can do for you.

Greg

saurabh_gotharw
Champ in-the-making
Champ in-the-making

I am trying to fetch content of attached files using api call on activiti version 5.22.0. For "text" files, I am able to save content in a local file but for rest of the formats (.pdf/ .jpeg), I am not getting proper content as the local files are getting corrupted and also size of local file is larger than the original file.

Can you elaborate though? I want to know things like, "when I use this file (size, type, etc), the API call works, but then I download the file and <something> happens". Are there any error messages? Does this seem to happen to all files other than text no matter what? Or does it work for smaller/larger files?

-JEarles

This is what I have found.

1. I am able to reproduce the issue using a simple pdf file.

2. The corruptions appears to occur on upload as the binary stream stored in the database matches the corrupted file.

3. Activiti Enterprise and Activiti Version 6 use a completely different API set and doesnt appear to have the same problem, at least using the new related content api.

The code itself appears to be correct, the Multipart data element is being pulled directly from the request using:

 MultipartFile file = request.getFileMap().values().iterator().next();

Then saved to the ACT_GE_BYTEARRAY table as a byte array. The Data is wrong as soon as it hits the database.

I have not attempted using any other file, but right now things don't look good.

Greg

saurabh_gotharw
Champ in-the-making
Champ in-the-making

Greg

As you said that this problem will not occur in Activiti Version 6, but is there any possibility that I can get correct content using Activiti Version 5.22 as migrating from version 5.22 to 6 will require major changes for us.

Activiti is open source software and maintained by the usr community.

Feel free to generate a fix and issue a pull request.

If you are incapable of unwilling to contribute, you can open a defect on the Activiti Jira here, but there is no guarantee when this will be fixed that way.

Alternatively, if this is really important to you, you could pay someone to fix the issue for you (such as BP3).

Greg