Quantcast
Channel: SCN : All Content - Web Dynpro ABAP
Viewing all articles
Browse latest Browse all 3667

Download image to my pc

$
0
0

Hello Friends,  I have a rerequirement to download the image to the pc(when user click a button),  I can upload to image to the table and show the image in a pop-up to users but i want the image to be downloadable at the same time,  How i show the image to the user is like below coding.

 

Thanks

 

method WDDOINIT .

 *

 * 
   DATA :   lo_cache            TYPE REF TO if_http_response,            lv_guid             TYPE        guid_32,            lv_host             TYPE        string,            lv_port             TYPE        string,            lv_protocol         TYPE        string,            lv_url              TYPE        string.   CREATE OBJECT lo_cache     TYPE     cl_http_response     EXPORTING       add_c_msg = 1.   SELECT * FROM my_table          INTO TABLE it_image where file_no eq lv_file_no.   lo_nd_image = wd_context->get_child_node( name = wd_this->wdctx_image ).

 * Generating the URL for the image.

   LOOP AT it_image INTO wa_image.     ls_image-file_no = wa_image-file_no.     ls_image-file_name = wa_image-file_name.

 * Setting the XString format of image content in the cache.

     lo_cache->set_data( wa_image-content ).     lo_cache->set_header_field( name  = if_http_header_fields=>content_type                                       value = 'image/jpeg' ).

 * Create a unique URL for the object

   CALL FUNCTION 'GUID_CREATE'     IMPORTING       ev_guid_32 = lv_guid.

 * Set the Response Status

      lo_cache->set_status( code = 200 reason = 'OK' ).

 * Set the timeout for the cache

       lo_cache->server_cache_expire_rel( expires_rel = 360 ).

 * Getting the host , port and Protocol of the server

       CALL METHOD cl_http_server=>get_location          EXPORTING            server       = cl_wdr_task=>server          IMPORTING            host         = lv_host            port         = lv_port            out_protocol = lv_protocol.

 * Generating the URL

       CONCATENATE          lv_protocol '://' lv_host ':' lv_port '/sap/bc/webdynpro/sap/'          lv_guid '.JPG'          INTO lv_url.

 * Upload the generated URL in the cache

         cl_http_server=>server_cache_upload( url      = lv_url                                             response = lo_cache ).     ls_image-image = lv_url.     APPEND ls_image TO lt_image.     CLEAR : wa_image, ls_image.   ENDLOOP.   lo_nd_image->bind_table( new_items = lt_image set_initial_elements = abap_true ).

 endmethod.


Viewing all articles
Browse latest Browse all 3667

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>