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

Google Storage for Developers API (GET / PUT files using ABAP)

Former Member
0 Likes
881

Does anyone have any experience using Google's Storage API from SAP/ABAP ?

We have a requirement to put files (txt, xls, etc.) out to Google Storage.

Here's a link with an overview of Google Storage:

http://code.google.com/apis/storage/docs/overview.html

Here's a link explaining the HTTP methods used:

http://code.google.com/apis/storage/docs/reference-methods.html#putobject

Unfortunately we do not have much in-house Java/Web development experience. We do have some experience with the "http_client" methods in SAP, but not the GET/PUT concept to push/receive files.

Does anyone have experience using SAP/ABAP to accomplish this requirement?

Anyone have any sample ABAP code which would illustrate how to put a simple TXT file out to Google Storage?

Thanks very kindly,

Chris

1 REPLY 1
Read only

mvoros
Active Contributor
0 Likes
507

Hi,

I haven't worked with Google Storage but I wrote a really simple class for working with CouchDB. Both products use REST based API so there should not be a big difference between them. Don't expect too much cause I spent just 1 hour on it but it might help you. The class cl_http_client is pretty straighforward so you shouldn't have any problems to add additional things required by Google.

Basically, I have one main method called SEND with three parameters METHOD, URL and DATA (all parameters have type string).


  DATA: full_url TYPE string,
        client TYPE REF TO if_http_client.

* Create HTTP Client
  CONCATENATE 'http://' me->host ':' me->port url
    INTO full_url.
  CALL METHOD cl_http_client=>create_by_url
    EXPORTING
      url                = full_url
    IMPORTING
      client             = client
    EXCEPTIONS
      argument_not_found = 1
      plugin_not_active  = 2
      internal_error     = 3
      OTHERS             = 4.

  IF sy-subrc <> 0.
* XXX
  ENDIF.

  IF NOT data IS INITIAL.
    client->request->append_cdata( data ).
  ENDIF.
  client->request->set_method( method ).
  client->send( ).
  client->receive( ).
  result = client->response.

Prety simple, you just need to enter method (GET,PUT,POST,DELETE) and URL. The parameter DATA is optional. Here is an example how I use my class.


* Get connection
  couch =  zcl_couchdb=>getcouchdb( ).
  result = couch->send( method = 'GET' url = '/' ).
  txt = result->get_cdata( ).
  WRITE: / txt.
  result = couch->send( method = 'GET' url = '/_all_dbs' ).
  txt = result->get_cdata( ).
  WRITE: / txt.

* Create DB
  result = couch->send( method = 'PUT' url = '/test' ).
  txt = result->get_cdata( ).
  WRITE: / txt.
  result = couch->send( method = 'GET' url = '/_all_dbs' ).
  txt = result->get_cdata( ).
  WRITE: / txt.

* Create a new document
  result = couch->send( method = 'PUT' url = '/test/123' data = '{"_id":"123","data":"Foo"}' ).
  txt = result->get_cdata( ).
  WRITE: / txt.

* Get back document 123
  result = couch->send( method = 'GET' url = '/test/123').
  txt = result->get_cdata( ).
  WRITE: / txt.