cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

problems with server cache

Former Member
0 Likes
1,096

hi,

i want to upload files to the server-cache, so that i can download them.

to do so, i used this code:


  DATA: cached_response TYPE REF TO if_http_response,
        guid TYPE guid_32,

  CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING add_c_msg = 1.

  cached_response->set_data( file-mimetype ).
  cached_response->set_content_type( file_mime_type ).
  cached_response->set_status( code = 200 reason = 'OK' ).
  cached_response->server_cache_expire_rel( expires_rel = 180 ).

  CALL FUNCTION 'GUID_CREATE'
    IMPORTING
        ev_guid_32 = guid.
    CONCATENATE runtime->application_url '/' guid INTO url.

  cl_http_server=>server_cache_upload( url      = url
                                       response = cached_response ).

the file describes a gif image

the file-content is an xstring (about 44KB) and the mimetype is image/gif

this should work, but in the browser i get this error message:

-

-


BSP Exception: Das Objekt 4603E7BA78A5008C000000000A4222CA in der URL /sap(bD1kZSZjPTAwMQ==)/bc/bsp/sap/myapplication/4603E7BA78A5008C000000000A4222CA ist nicht gültig.

-

-


i checked the file-content, the mime typ and the url.

everything is filled and seems to be valid values.

i debugged into the server_cache_upload method and the inner function call give a sy-subrc = 0, so it seems also be good.

but i can not download the file from the server.

the strange thing is, that this code already worked, until i changed the source from witch i load my file-content.

but in case of a bad file content the browser should also download and try to show me, right?

at my tries of changing the sourceloader i make some errors and i created some empty responses, because the file-content wasnt loaded.

could it be that these attempts of creating empty responses somewhere destroyed the server-cache?

hopefully Grafl Ronald

View Entire Topic
raja_thangamani
Active Contributor
0 Likes

correct your code with below correct..

    l_pdf_len = xstrlen( l_pdf_xstring ).
    cached_response->set_data( data   = l_pdf_xstring
                        length = l_pdf_len ).

    cached_response->set_header_field( name  = if_http_header_fields=>content_type
                                       value = file_mime_type  ). "'application/pdf'
    cached_response->set_status( code = 200 reason = 'OK' ).
    cached_response->server_cache_expire_rel( expires_rel = 180 ).

apart of the above change, everything is fine..

<i>* Reward each useful answer</i>

Raja T

Former Member
0 Likes

thanks for your reply

i switched back to the

set_header_field method and also set the correct length in the set_data method, but it still wont work

raja_thangamani
Active Contributor
0 Likes

What is the value of "file_mime_type" & URL now?

Raja T

Former Member
0 Likes

file_mime is 'image/gif'

and url is: '/sap(bD1kZSZjPTAwMQ==)/bc/bsp/sap/zzjobboerse_ad/4603F2CE78A5008C000000000A4222CA'

raja_thangamani
Active Contributor
0 Likes

add .<b>gif to the URL</b> & test.. it should work..

I mean, ur URL will look like

/sap(bD1kZSZjPTAwMQ==)/bc/bsp/sap/zzjobboerse_ad/4603F2CE78A5008C000000000A4222CA.GIF

If it works make it dynamic.

Raja T

Former Member
0 Likes

i tried with less hope, but doesnt work.

as i thought, the content type is described in the http header.

this means also that it would not matter what kind of data is stored under this cached id.

it looks like the caching service wont work, but i have no clue how this could happen.

Former Member
0 Likes

very very strange

we tried to find the problem with the smicm

and now it works xD.

dont know why, we didnt something else than show statistik and cache entries 😃

mfg Grafl Ronald

--

The problem appears again

--

We solved the Problem.

it seems that the server-cache is somewhere connected to the spool.

Message was edited by:

Grafl Ronald