cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic image expires after few minutes

Former Member
0 Kudos

CREATE OBJECT CACHED_RESPONSE

TYPE

CL_HTTP_RESPONSE

EXPORTING

ADD_C_MSG = 1.

TRY. " ignore, if compression can not be switched on

CALL METHOD CACHED_RESPONSE->SET_COMPRESSION

EXPORTING

OPTIONS = CACHED_RESPONSE->CO_COMPRESS_BASED_ON_MIME_TYPE

EXCEPTIONS

OTHERS = 1.

CATCH CX_ROOT.

ENDTRY.

****set the data and the headers

CACHED_RESPONSE->SET_DATA( ITEM_IMAGE_UPLOAD ).

L_APP_TYPE = 'JPG'.

CACHED_RESPONSE->SET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=>CONTENT_TYPE

VALUE = L_APP_TYPE ).

***SET THE RESPONSE STATUS

CACHED_RESPONSE->SET_STATUS( CODE = 200 REASON = 'OK' ).

****Set the Cache Timeout - 60 seconds - we only need this in the cache

****long enough to build the page and allow the Image on the Client to request it.

CACHED_RESPONSE->SERVER_CACHE_EXPIRE_REL( EXPIRES_REL = I_CACHE_TIMEOUT ).

****Create a unique URL for the object

CALL FUNCTION 'GUID_CREATE'

IMPORTING

EV_GUID_32 = GUID.

CONCATENATE '/sap/public/' GUID '.jpg' INTO R_URL.

****Cache the URL

CL_HTTP_SERVER=>SERVER_CACHE_UPLOAD( URL = R_URL

RESPONSE = CACHED_RESPONSE ).

ELEM_IMAGE_UPLOAD->SET_ATTRIBUTE( EXPORTING NAME = `IMAGE_SOURCE_V10` VALUE = R_URL ).

The above coding uploads the image to sap but after few minutes the image expires at the runtime........Plz tell me where i am getting the problem..........

Thanks and regards,

Alagappan.S

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You are setting the server side timeout for the cached entry right here:

CACHED_RESPONSE->SERVER_CACHE_EXPIRE_REL( EXPIRES_REL = I_CACHE_TIMEOUT ).

If you need it longer, increase the value in I_CACHE_TIMEOUT.