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: 答復(fù): Need technique support for UI5 plugin: uploadCollection
我對(duì)比了你們那個(gè)opportunities的附件上傳功能:
我們的ui version是1.28.3, 你們的是1.28.5
Debug進(jìn)去插件的框架,在我們那個(gè)報(bào)錯(cuò)的程序那里,兩個(gè)版本的邏輯差別還是比較大:
報(bào)錯(cuò)的calling stack: FileUploader.upload() àFileUploader.sendFiles()
1.28.3: FileUploader.sendFiles() 從黃色的地方就開(kāi)始報(bào)錯(cuò)了,跳出來(lái)了
1.28.5 FileUploader.sendFiles() 從黃色的地方繼續(xù)向下執(zhí)行,直到成功上傳。 這兩個(gè)部分的邏輯是不一樣的。
但是我應(yīng)用的controller, 如何設(shè)置uploadCollection是幾乎和你們的是一樣的。我們現(xiàn)在附件終于可以上傳了
我們最終的解決辦法還是沒(méi)有Opportunity一樣的發(fā)relative path,我看了那個(gè)relative path的值,很難理解,感覺(jué)像是和后臺(tái)ABAP系統(tǒng)暴露的某個(gè)service的值有關(guān)系。
Yaas這里恐怕行不通。
我這里解決問(wèn)題的思路是:
否則,默認(rèn)情況下:“userMultiplePart”的屬性為false, 直接把文件作為參數(shù)傳過(guò)去就報(bào)415-Unsupported media type的錯(cuò)誤。
3. 我的實(shí)現(xiàn)方式:
在上傳文件以前,取出FileUploader(是每一個(gè)item對(duì)應(yīng)的上傳插件). 設(shè)置property useMultipart 為true.
在開(kāi)放JS里面,
可以利用這樣的代碼: FormData forData1= new FormData(); forData1.append(‘file’, uploadeFile); 再調(diào)用AJAX 的POST方法,來(lái)實(shí)現(xiàn)文件上傳,正好這里的代碼和928后面的邏輯是完全一樣的。
要獲取更多Jerry的原創(chuàng)文章,請(qǐng)關(guān)注公眾號(hào)"汪子熙":
總結(jié)
以上是生活随笔為你收集整理的UI5 plugin - uploadCollection的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 发改委:推动新能源车下乡 车企应多开发适
- 下一篇: 什么是COS操作系统