Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Get File Through HTTP

Former Member
0 Likes
567

Hi,

I need to transfer a file residing on the servers' HDD via HTTP to a client. The file can be transferred via web service or basic HTTP Response. How can I accomplish that?

thanks,

2 REPLIES 2
Read only

Former Member
0 Likes
498

Hi Ferudun,

Did you read the post http://scn.sap.com/thread/1646766 ?

Perhaps it can help you to send the file via http post.

Regards,

Christian

Read only

Former Member
0 Likes
498

Here is a summary of how to do it with an HTTP Post:

data: lo_http_client type REF TO if_http_client,
      l_file         type xstring.


cl_http_client=>create(
  EXPORTING
    host               = `example.com/target/path`
  IMPORTING
    client             = lo_http_client ).

lo_http_client->request->set_method(
  if_http_request=>co_request_method_post ).

OPEN DATASET my_file FOR INPUT IN BINARY MODE.
  ... "Fill l_file
CLOSE DATASET my_file.

lo_http_client->request->set_data( l_file ).

* Replace text/html with appropriate MIME type
lo_http_client->request->set_content_type( `text/html` ).

lo_http_client->send( ).