cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

corrupt data when uploading html file with GUI_UPLOAD

EnnoWulff
Active Contributor
0 Likes
1,902

Hi there!

When uploading an html file with GUI_UPLOAD and filetype 'BIN' I get corrupt data like this:

਍ℼⴭ猠癡摥映潲牵㵬〨㌱⤲楦敬⼺⼯㩃唯敳獲眯湩汫牥⽣灁䑰瑡⽡潌慣⽬楍牣獯景⽴楗摮睯⽳义瑥慃档⽥潃瑮湥⹴畏汴潯⽫䝕㙐婊婐匯䥁呎佟充〰〲ㄷ㈳ㄸ㉟㈰〴㈲ㄸ㈴㐵⸷瑨汭ⴠ㸭਍格浴㹬格慥⁤浸湬㩳瑴∽瑨灴⼺眯睷献灡挮浯琯慲獮潦浲瑡潩⵮整灭慬整≳㰾敭慴栠瑴⵰煥極㵶䌢湯t 湥⵴祔数•潣瑮湥㵴琢硥⽴瑨汭※档牡敳ãµ

The file length is correct.

When uploading text files, I get chinese characters

瑥整牲楥敦Ɱ洠瑩搠牥䈠瑩整

Afterwards I use FM SO_DOCUMENT_INSERT_API1 to add the uploaded file to GOS.

It works with images and office files. but html and text files do not work.

I also tried different code pages (utf-8, utf-16) at GUI_UPLOAD w/o success.

Any ideas?

Thanks

~Enno

Accepted Solutions (1)

Accepted Solutions (1)

EnnoWulff
Active Contributor
0 Likes

The problem seemed to be that because of the document type or file extension "TXT", the binary content was interpreted as "text" by simply copying the binary content table into the text content table. 

I still do not know when or why this behaviour had changed.

This is an alternative to the process:

 

      DATA(lo_gos_api) = cl_gos_api=>create_instance(
        VALUE #(
          instid = CONV #( p_myid )
          typeid = 'MYTYPEID'
          catid  = 'BO' ) ).

      DATA(ls_attcont) = VALUE gos_s_attcont(
        atta_id   = 'MYTYPEID'
        atta_cat  = cl_gos_api=>c_msg
        cr_user   = sy-uname
        cr_name   = space
        cr_date   = sy-datum
        cr_time   = sy-uzeit
        filesize  = filelength
        filename  = zcl_devt_file=>get_filename_from_path( p_file )
        tech_type = zcl_devt_file=>get_extension_from_filename( p_file )
        descr     = p_descr
        lang      = sy-langu
        content   = space
        content_x = cl_bcs_convert=>xtab_to_xstring( lt_contx ) ).
      lo_gos_api->insert_al_item(
        EXPORTING
          is_attcont = ls_attcont
          iv_roltype = cl_gos_api=>c_attachment
        IMPORTING
          ev_atta_id = DATA(ev_atta_id)
        RECEIVING
          rv_commit  = DATA(commit_required)   ).
      IF commit_required = abap_true.
        COMMIT WORK.
        "file has been added.
        MESSAGE i036 WITH p_bugid.
      ENDIF.

 

 

chaouki_akir
Contributor
0 Likes
What was the problematic code ?

Answers (0)