UI5 plugin - uploadCollection
Sent: Friday, 15 April, 2016 4:45 PM
Here’ s my steps to use uploadCollection.
Step1: Set URL for this plugin in method “initAttach……”, this method will be called by controller standard method “onInit”.
Step2: When files are changed on UI, call handler method: “onAttachmentChange” to set some parameters for UPloadCollection plugin.
Which are almost the same as your implementation in opportunity attachments.
My Problems:
The request to upload file are always meet “HTTP Type 415 upported media type”.
I didn’t set the “content-type” specially, as you did in the opportunities UI (s3.controller), the uploaded content-type is “image/jpeg”.
By the way, I also check the your opportunities UI, the content-type for submit request is also “image/jpeg”.
URL:
https://hybris-cecenter-agenthome-ui-test-v1.us-east.modules.yaas.io/?client_id=YGJmifyZdXmoJTHOQjRD0CZy67NdQqwj
Reproduce steps:
Sent: Friday, 15 April, 2016 5:54 PM
Subject: 答復: Need technique support for UI5 plugin: uploadCollection
我對比了你們那個opportunities的附件上傳功能:
我們的ui version是1.28.3, 你們的是1.28.5
Debug進去插件的框架,在我們那個報錯的程序那里,兩個版本的邏輯差別還是比較大:
報錯的calling stack: FileUploader.upload() àFileUploader.sendFiles()
1.28.3: FileUploader.sendFiles() 從黃色的地方就開始報錯了,跳出來了
1.28.5 FileUploader.sendFiles() 從黃色的地方繼續向下執行,直到成功上傳。 這兩個部分的邏輯是不一樣的。
但是我應用的controller, 如何設置uploadCollection是幾乎和你們的是一樣的。我們現在附件終于可以上傳了
我們最終的解決辦法還是沒有Opportunity一樣的發relative path,我看了那個relative path的值,很難理解,感覺像是和后臺ABAP系統暴露的某個service的值有關系。
Yaas這里恐怕行不通。
我這里解決問題的思路是:
否則,默認情況下:“userMultiplePart”的屬性為false, 直接把文件作為參數傳過去就報415-Unsupported media type的錯誤。
3. 我的實現方式:
在上傳文件以前,取出FileUploader(是每一個item對應的上傳插件). 設置property useMultipart 為true.
在開放JS里面,
可以利用這樣的代碼: FormData forData1= new FormData(); forData1.append(‘file’, uploadeFile); 再調用AJAX 的POST方法,來實現文件上傳,正好這里的代碼和928后面的邏輯是完全一樣的。
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
總結
以上是生活随笔為你收集整理的UI5 plugin - uploadCollection的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 发改委:推动新能源车下乡 车企应多开发适
- 下一篇: 什么是COS操作系统