cancel
Showing results for 
Search instead for 
Did you mean: 

Download .DOCX from DMS, File Corrupted

Former Member
0 Kudos

We have a requirement where we need to upload files (doc, docx, xls, xlsx, png, pdf, txt, jpg) to DMS and download back from DMS. We are using NWDS 7.3

The upload happens fine, we are able to open files from DMS.

But when trying to download the .docx type of file from portal, we get a corrupted file. Word prompts to repair the file, after repair file opens well.

All other file types except the Office 2007+ are working well.

I am using the below code:

String Filename = docDownloadInput.getOutput().getCp_Doc_Files().get(0).getDocfile();

int fileLength = docDownloadInput.getOutput().getCp_Content().size();

ByteArrayOutputStream boStream = new ByteArrayOutputStream();

for(int j=0;j<fileLength;j++){

try {

                boStream.write(docDownloadInput.getOutput().getCp_Content().get(j).getLine());

            } catch (IOException e) {

                // TODO Auto-generated catch block

                e.printStackTrace();

            }

          }

        if(boStream.size()>0)

        {

                IWDResource resource = WDResourceFactory.createResource(boStream.toByteArray(),Filename, type);

                resource.download(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal());

               

        }

Kindly let me know what can be done in this scenario.

Accepted Solutions (0)

Answers (2)

Answers (2)

alisonv
Explorer
0 Kudos

DATA: lt_access_info TYPE TABLE OF sdokfilaci,

      lt_ascii_content     TYPE TABLE OF sdokcntasc,
lt_binary_content TYPE TABLE OF sdokcntbin.
DATA: lv_doc_lenght TYPE i,
lv_qty_lines TYPE i,
lv_xstring TYPE xstring.

CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = w_object_id
raw_mode = 'X'
TABLES
file_access_info = lt_access_info
file_content_ascii = lt_ascii_content
file_content_binary = lt_binary_content
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
OTHERS = 5.
 IF sy-subrc <> 0.
RETURN.
ENDIF.

FIELD-SYMBOLS: <lt_access_info> LIKE LINE OF lt_access_info.
READ TABLE lt_access_info ASSIGNING <lt_access_info> INDEX 1.
IF sy-subrc IS INITIAL AND <lt_access_info>-file_size IS NOT INITIAL.
lv_doc_lenght = <lt_access_info>-file_size.
ELSE.
lv_qty_lines = lines( lt_binary_content ).
lv_doc_lenght = lv_qty_lines * 1022.
ENDIF.

Former Member
0 Kudos

Hi,

what was the solution here? I have the same problem.

Thanks

Former Member
0 Kudos

Dear

Update your msoffice verison  update your java verison to latest then it will work

Regards