@EndUserText.label : 'Files'
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #LIMITED
define table zfile {
key client : abap.clnt not null;
key id : uuid not null;
filename : char255;
sydate : dats;
sytime : tims;
value : xstringval;
mimetype : char100;
}
METHOD define.
super->define( ).
DATA: lo_entity TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
lo_property TYPE REF TO /iwbep/if_mgw_odata_property.
lo_entity = model->get_entity_type( iv_entity_name = 'File' ).
IF lo_entity IS BOUND.
lo_property = lo_entity->get_property( iv_property_name = 'FileName').
lo_property->set_as_title( ).
lo_property = lo_entity->get_property( iv_property_name = 'MIMEType').
lo_property->set_as_content_type( ).
ENDIF.
ENDMETHOD.
method fileset_get_entity.
DATA lw_pk TYPE zfile.
" DO. ENDDO.
READ TABLE it_key_tab INTO DATA(lw_key_tab) WITH KEY name = 'ID'.
IF sy-subrc = 0.
SELECT single id, filename, sydate, sytime, mimetype from zfile into CORRESPONDING FIELDS OF @lw_pk where id = @lw_key_tab-value.
ENDIF.
er_entity = lw_pk.
endmethod.
METHOD fileset_get_entityset.
DATA:
it_final TYPE STANDARD TABLE OF zfile,
lt_filters TYPE /iwbep/t_mgw_select_option,
ls_filter TYPE /iwbep/s_mgw_select_option,
ls_so TYPE /iwbep/s_cod_select_option,
p_name TYPE c LENGTH 15.
SELECT
id
filename
sydate
sytime
"value
mimetype
FROM zfile
INTO CORRESPONDING FIELDS OF TABLE et_entityset.
ENDMETHOD.
METHOD /iwbep/if_mgw_appl_srv_runtime~create_stream.
DATA: lw_file TYPE zfile.
lw_file-id = cl_system_uuid=>create_uuid_x16_static( ).
lw_file-filename = iv_slug.
lw_file-value = is_media_resource-value.
lw_file-mimetype = is_media_resource-mime_type.
lw_file-sydate = sy-datum.
lw_file-sytime = sy-uzeit.
INSERT INTO zfile VALUES lw_file.
TRY.
DATA : ls_key_tab TYPE /iwbep/s_mgw_name_value_pair,
lt_key_tab TYPE /iwbep/t_mgw_name_value_pair.
DATA: ls_filemetadata TYPE zfile.
DATA: lw_key_tab LIKE LINE OF it_key_tab.
" data: lt_key_tab TYPE /iwbep/t_mgw_name_value_pair.
lw_key_tab-name = 'ID'.
lw_key_tab-value = lw_file-id.
APPEND lw_key_tab TO lt_key_tab.
CALL METHOD fileset_get_entity
EXPORTING
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
it_key_tab = lt_key_tab
* io_request_object =
* io_tech_request_context =
it_navigation_path = it_navigation_path
IMPORTING
er_entity = ls_filemetadata.
* es_response_context =
copy_data_to_ref(
EXPORTING
is_data = ls_filemetadata
CHANGING
cr_data = er_entity ).
"do. enddo.
CATCH /iwbep/cx_mgw_busi_exception.
CATCH /iwbep/cx_mgw_tech_exception.
ENDTRY.
ENDMETHOD.
method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM.
DATA : ls_stream TYPE ty_s_media_resource,
ls_upld TYPE zfile.
DATA: lv_id TYPE zfile-id.
FIELD-SYMBOLS:<fs_key> TYPE /iwbep/s_mgw_name_value_pair.
DATA ls_header TYPE ihttpnvp.
ls_header-name = 'Content-Disposition'.
READ TABLE it_key_tab ASSIGNING <fs_key> with key name = 'ID'.
lv_id = <fs_key>-value.
SELECT SINGLE * FROM zfile INTO ls_upld WHERE id = lv_id.
IF ls_upld IS NOT INITIAL.
ls_stream-value = ls_upld-value.
ls_stream-mime_type = ls_upld-mimetype.
ls_header-value = 'outline; filename="' && ls_upld-filename && '";'.
set_header( is_header = ls_header ).
copy_data_to_ref( EXPORTING is_data = ls_stream CHANGING cr_data = er_stream ).
ENDIF.
endmethod.
<UploadCollection
maximumFilenameLength="55"
maximumFileSize="1000"
fileDeleted="onFileDeleted"
filenameLengthExceed="onFilenameLengthExceed"
fileRenamed="onFileRenamed"
fileSizeExceed="onFileSizeExceed"
id="UploadCollection"
change="onChange"
mode="SingleSelectMaster"
beforeUploadStarts="onBeforeUploadStarts"
items="{path: '/FileSet'}" multiple="true"
uploadUrl="/sap/opu/odata/sap/ZFILE_EX_SRV/FileSet"
uploadComplete="onUploadComplete" noDataText="No files found."
noDataDescription="Drop files to upload, or use the "+" button.">
<items>
<UploadCollectionItem
documentId="{ID}"
fileName="{FileName}"
url="/sap/opu/odata/sap/ZFILE_EX_SRV/FileSet(guid'{ID}')/$value"
mimeType="{MIMEType}"
enableEdit="false"
enableDelete="false"
visibleDelete="false"
visibleEdit="false">
</UploadCollectionItem>
</items>
</UploadCollection>
onInit: function () {
var oUploadCollection = this.getView().byId('UploadCollection');
oUploadCollection.setUploadUrl("/sap/opu/odata/sap/ZFILE_EX_SRV/FileSet");
var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZFILE_EX_SRV",false);
this.getView().setModel(oModel);
}
onBeforeUploadStarts: function (oEvent) {
var oCustomerHeaderSlug = new sap.m.UploadCollectionParameter({
name: "slug",
value: oEvent.getParameter("fileName")
});
oEvent.getParameters().addHeaderParameter(oCustomerHeaderSlug);
var oModel = this.getView().getModel();
oModel.refreshSecurityToken();
var oHeaders = oModel.oHeaders;
var sToken = oHeaders['x-csrf-token'];
var oCustomerHeaderToken = new sap.m.UploadCollectionParameter({
name: "x-csrf-token",
value: sToken
});
oEvent.getParameters().addHeaderParameter(oCustomerHeaderToken);
}
onUploadComplete: function(oEvent){
this.getView().getModel().refresh();
}
{
"path": "/sap/opu/odata",
"target": {
"type": "destination",
"name": "SG7_OnPremise",
"entryPath": "/sap/opu/odata"
},
"description": "SG7_OnPremise"
}
"_version": "1.12.0",
"sap.app": {
"id": "dsn.File",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"version": "1.40.12"
},
"dataSources": {
"mainService": {
"uri": "/sap/opu/odata/sap/ZFILE_EXT_SRV/",
"type": "OData",
"settings": {
"annotations": [
"ZFILE_EXT_ANNO_MDL"
],
"localUri": "localService/metadata.xml"
}
},
"ZFILE_EXT_ANNO_MDL": {
"uri": "/sap/opu/odata/IWFND/CATALOGSERVICE;v=2/Annotations(TechnicalName='ZFILE_EXT_ANNO_MDL',Version='0001')/$value/",
"type": "ODataAnnotation",
"settings": {
"localUri": "localService/ZFILE_EXT_ANNO_MDL.xml"
}
}
}
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |