在OData NetWeaver Gate方式中使用SAP ui5上传集合时出现问题

2020-09-13 14:08发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)我在视图中使用以下代码创建了上传...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


我在视图中使用以下代码创建了上传集合:

id =" UploadCollection"
maximumFilenameLength =" 55"
maximumFileSize =" 10"
multiple =" true"
sameFilenameAllowed =" true"
InstantUpload = " false"

noDataDescription ="删除文件或使用" +"按钮等待上载"
change =" onChange"
fileDeleted =" onFileDeleted"
filenameLengthExceed =" onFilenameLengthExceed" < br> fileSizeExceed =" onFileSizeExceed"
typeMissmatch =" onTypeMissmatch"
uploadComplete =" onUploadComplete"
beforeUploadStarts =" onBeforeUploadStarts"/>

在控制器中,我在init方法中添加了以下代码:

this.getView()。byId(" UploadCollection")。setUploadUrl("/img/sap/opu/odata/sap/ZLEAVE_REQUEST_ODATA_SRV/ATTATCHENTSet");

并在控制器中添加了以下方法:

onChange:函数(oEvent){
var oUploadCollection = oEvent.getSource();
//标头令牌
var oCustomerHeaderToken = new sap.m.UploadCollectionParameter({
name:" x -csrf-token",
值:" L5_R1qa_PlV7fZqfgIMlQw =="
});
oUploadCollection.addHeaderParameter(oCustomerHeaderToken);
//MessageToast.show("已触发事件更改");
>},
onBeforeUploadStarts:function(oEvent){
//标头Slug
var oCustomerHeaderSlug = new sap.m.UploadCollectionParameter({
name:" slug",
value:oEvent。 getParameter(" fileName")
});
oEvent.getParameters()。addHeaderParameter(oCustomerHeaderSlug);
setTimeout(function(){
//MessageToast.show("事件在触发UpUploadStarts之后") ;
},4000);
},

onUploadComplete:function(oEvent){
var sUploadedFileName = oEvent.getParameter(" files")[0] .fileName;
setTimeout(function(){
var oUploadCollection = this.byId(" UploadCollection");

for(var i = 0; i if(oUploadCollection.getItems()[i] .getFileName()=== sUploadedFileName){
oUploadCollection.removeItem(oUploadCollection.getItems()[i]);
中断;
}
}

//延迟成功消息,以便在此之前查看其他消息
//MessageToast.show("已触发事件uploadComplete");
} .bind(this) ,8000);
},
onStartUpload:function(oEvent){
var oUploadCollection = this.byId(" UploadCollection");
//var oTextArea = this.byId(" TextArea") ;
var cFiles = oUploadCollection.getItems()。length;
var uploadInfo = cFiles +" file(s)";

if(cFiles> 0){
oUploadCollection.upload( );

//MessageToast.show("方法上传称为(" + uploadInfo +")"));
//MessageBox.information(" Uploaded" + uploadInfo);
// oTextArea.setValue("");
}
},

onSelectChange:function(oEvent){
var oUpUpCollection = this.byId(" UploadCollection");
oUploadCollection。 setShowSeparators(oEvent.getParameters()。selectedItem.get Property(" key"));
},

并在odata中重新定义了create_stream方法,但我的方法未触发,并且在控制台中我发现以下错误:

POST http://localhost:56740/sap/opu/odata/sap/ZLEAVE_REQUEST_ODATA_SRV/ATTATCHENT设置403(禁止)。

我迫切需要您的帮助,并且需要sap ui5上传集合和netweaver Gate方式odata的示例。