on 05-08-2015 4:44 PM
Hi all!
I have faced with a strange behavior of a FileUpload control in IE.
I have a service for file parsing. I should send a file from a client on a server and receive json data in response.
Code example:
<script>
var fu = new sap.ui.unified.FileUploader({
id:"__uploader999",
uploadUrl : "/_service_/parse",
uploadOnChange : true,
fileType : "csv",
maximumFileSize : 1,
buttonOnly : true,
icon : "sap-icon://upload",
uploadComplete : [ function(oEvent) {
alert(oEvent.getParameter("response"))
}, this ],
typeMissmatch : [ function(oEvent) {
sap.m.MessageToast.show("typeMissmatch");
}, this ],
fileSizeExceed : [ function(oEvent) {
sap.m.MessageToast.show("fileSizeExceed");
}, this ],
fileAllowed : [ function(oEvent) {
sap.m.MessageToast.show("fileAllowed");
}, this ],
uploadProgress : [ function(oEvent) {
sap.m.MessageToast.show("uploadProgress");
}, this ],
uploadAborted : [ function(oEvent) {
sap.m.MessageToast.show("uploadAborted");
}, this ],
filenameLengthExceed : [ function(oEvent) {
sap.m.MessageToast.show("filenameLengthExceed");
}, this ]
})
fu.placeAt("content");
</script>
It works fine in Chrome and I have a data in responseComplete.
But IE9 and IE10 saves the response automatically and responseComplete event doesn't fire.
May someone have faced this?
Thanks in advance!
Solved!
content-type = text/plain in response.
internet explorer - Json response download in IE(7~10) - Stack Overflow
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raman,
I've a similar problem to yours: http://scn.sap.com/thread/3837313
My java code looks like this:
JSONObject j = new JSONObject();
j.put("status", "200");
j.put("fileName", fileName + "." + fileExt);
String utfString = j.toString();
//response.setHeader("Content-Type", "application/json; charset=UTF-8");
//response.setHeader("Content-Type", "text/html; charset=UTF-8");
//response.setContentType("application/json");
response.setHeader("Content-Type", "text/plain; charset=UTF-8");
//response.setContentType("text/plain");
//response.setContentType("text/html");
if (utfString != null) {
try {
utfString = new String(utfString.getBytes("UTF-8"),"UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Error writing to response", e);
}
}
response.getWriter().write(utfString);
I can see the correct response in the browser but I cannot access the response from the control event 'uploadComplete'.
Can you please share your code?
Regards,
Omri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Raman, post response headers from that service "/_service_/parse"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Raman,
Not specifically this issue, but I have encountered similar issues (browser version specific) with various File upload controls.
First thing you can do is to ensure you have the latest UI5 library on the server. That solved most issues for me.
After that it is trial and error and lots of luck.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.