0
我正在使用sap.ui.unified.FileUploader
上傳文件。我也加入slug
和X-CSRF-Token
在header
。但我不能發送頭值到網關,意味着網關側csrf token
值blank.I與Rest Client
測試了它的做工精細SAPUI5:文件上傳器不工作
代碼:
查看
<u:FileUploader
id="fileUploader1"
name="myFileUpload"
mimeType ="image,text"
uploadUrl=""
uploadOnChange="false"
width="400px"
tooltip="Upload your file to the local server"
uploadComplete="handleUploadComplete" />
<Button
text="Upload File"
press="handleUploadPress" />
控制器
handleUploadPress: function (oEvent) {
var url = "http://xxxxx.xxxx.xxxx:1234/sap/opu/odata/sap/ZGW_GC1_SRV/GCUpload1Set";
var oFileUploader = this.getView().byId("fileUploader1");
oFileUploader.addHeaderParameter(new sap.ui.unified.FileUploaderParameter({
name: "slug",
value: oFileUploader.getValue()
}));
oFileUploader.addHeaderParameter(new sap.ui.unified.FileUploaderParameter({
name: "x-csrf-token",
value: oController.oModel.getSecurityToken()
}));
oFileUploader.addHeaderParameter(new sap.ui.unified.FileUploaderParameter({
name: "sendXHR",
value: true
}));
oFileUploader.setUploadUrl(url);
你正在設置頭部參數'x-csrf-token'兩次。難道變量'token'是未定義的嗎? (你應該使用''use strict''命令來避免使用未聲明的變量。) – bgerth