Sapui5 opa5 How to upload a file using opa5 script

风流意气都作罢 提交于 2020-07-24 05:41:04

问题


im facing an issue in Uploading a file using OPA5 Script. Can you please help me.

Please look my code..

xml::

<sap.ui.unified:FileUploader
                    id="fileUploader"
                    name="myFileUpload"
                    uploadUrl="upload/"
                    width="400px"
                    tooltip="Upload your file to the local server"
                    />

OPA Script ::

When.waitFor({
                            id: "fileUploader",
                            viewName: sViewName,
                            //actions: new Press(),
                            success : function (oFirstItem) {
                                oFirstItem.$().trigger("tap");
                                Opa5.assert.ok(true, "Upload Dialog got opened");
                            },
                            errorMessage: "Form Was not Submitted"
                        });

Can you please help me to apply right code to upload a file using OPA script.

Thank you in advance


回答1:


If you don't really want to upload a real file, you can pass parameters to the fireChange function. You can use action:

 actions: function (oFileUploader) {
                            var mParameters = {
                                files: {
                                    "0": {
                                        "name": "something",
                                        "type": "application/gzip",
                                        "size": 123,
                                        "lastModifiedDate": "2013-08-14T09:42:09.000Z",
                                        "webkitRelativePath": ""
                                    },
                                    "length": 1
                                },
                                newValue: "\"newValueOfTheFile.tgz\" "
                            };

                            oFileUploader.fireChange(mParameters);
                        }

Then you can use fireUploadComplete function (to tell that upload is finished) in the same action, or in another (if you want to check something while "uploading" the file.



来源:https://stackoverflow.com/questions/45605572/sapui5-opa5-how-to-upload-a-file-using-opa5-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!