===== Managing files in web server via HTTP ===== ==== Files and Directory management ==== I wrote these ABAP functions when I had to read/write from a BSP application a lot of PDF from/to a SAP Portal used as repository (PDF was stored in KM). \\ Below the ABAP functions which reflect four methods supported by **[[http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol|HTTP]] 1.0** protocol: ***[[programming:abap:http_head|z_http_HEAD]]** - checks if a file exist returning only the header ***[[programming:abap:http_get|z_http_GET]]** - reads a file from the HTTP server ***[[programming:abap:http_put|z_http_PUT]]** - writes a file in HTTP server ***[[programming:abap:http_delete|z_http_DELETE]]** - delete a file in HTTP server Using **HTTP 1.1** protocol, an extension for [[http://www.webdav.org/specs/rfc2518.html|Distributed Authoring (WEBDAV)]], additional methods are available. The web server must support the HTTP 1.1 protocol, but today all of them support this extension.\\ So I completed the job with the following functions: ***[[programming:abap:http_copy|z_http_COPY]]** - copy a file in the __same__ HTTP server ***[[programming:abap:http_mkcol|z_http_MKCOL]]** - creates directory in HTTP server (recursively) Using the above functions, I also wrote an additional one to RENAME files in HTTP server: ***[[programming:abap:http_rename|z_http_RENAME]]** - renames a file in HTTP server ==== File Properties (metadata) management ==== If a web server is WebDav enabled, it's possible to link custom properties to every file (for example a title, a project code, etc.). For this purpose, I wrote the two following functions that read and write custom properties: ***[[programming:abap:http_property_get|z_http_PROPERTY_GET]]** - reads all properties for a file ***[[programming:abap:http_property_set|z_http_PROPERTY_SET]]** - writes single/many properties for a file Unfortunately SAP Portal seems to ignore the write custom properties request and no error is returned ("All done, dude !"). With Tomcat or Apache as web server all works fine. User and password are hard coded in ABAP functions for example purpose, but it's advisable to put them in a customizing table or passing as parameters