Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] Get Filename and Mimetype from uploaded file

    DATA data_tab TYPE solix_tab.
    DATA filename TYPE string.
    DATA path     TYPE string DEFAULT 'C:\Users\path\to\my\file.pdf'.

    cl_gui_frontend_services=>gui_upload( EXPORTING filename   = path )
                                                    filetype   = 'BIN'
                                          CHANGING  data_tab   = data_tab ).

    CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
      EXPORTING
        full_name     = path 
      IMPORTING
        stripped_name = filename
      EXCEPTIONS
        x_error       = 1
        OTHERS        = 2.

    DATA(file_extension) = /iwwrk/cl_mgw_workflow_rt_util=>get_extention_from_file_name( filename ).
    DATA(mimetype)       = /iwwrk/cl_mgw_workflow_rt_util=>get_mime_type_from_extension( file_extension ).

[ABAP] Create DATA-URL from xstring

https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs

DATA lv_filetype TYPE char4.
DATA lv_content  TYPE xstring.

" get your data, for example a jpg
" lv_filetype = 'jpg'
" lv_content = ....

DATA(mimetype) = /iwwrk/cl_mgw_workflow_rt_util=>get_mime_type_from_extension( lv_filetype ).
DATA(base64)   = /iwwrk/cl_mgw_workflow_rt_util=>base64_encode( lv_content ).

DATA(lv_data_url) = |data:{ mimetype };base64,{ base64 }|.