‎2008 Jul 07 7:27 AM
Hi,
I'm trying to send a binary file to a http form via cl_http_client.
The webserver is awaiting the binary data with the name 'file'.
My problem is, that I don't know how I can set the name for the binary data.
When I send the data via:
CALL METHOD client->request->if_http_entity~set_form_field
EXPORTING
name = 'file'
value = binary_data.
the webserver interprets this as a string and not as a file.
How can I send the data as a file and the name 'file'?
Thanks for your help!
Christian
‎2008 Jul 07 10:00 AM
I found the solution myself:
part = client->request->add_multipart( ).
CALL METHOD part->set_header_field
EXPORTING
name = 'content-disposition'
value = 'form-data;name="file"; filename="file.bin";'.
CALL METHOD part->set_header_field
EXPORTING
name = 'content-type'
value = 'bin'.
OPEN DATASET '/file.bin FOR INPUT IN BINARY MODE.
read dataset '/file.bin' into data.
len = xstrlen( data ).
CALL METHOD part->set_data
EXPORTING
data = data
offset = 0
length = len.