Error sending an image to bubble (IE11) using webSDK
BeantwortetHi,
I am getting the following error then sending an image to a bubble with IE11?
Console log:
%c Mon Aug 13 2018 07:37:01 | RBW-SDK | StorageSrv | [addFileBub ] :: Try to add a file https://esben-lt:8010/images/Prisoners_dilemma_diagram.jpg to the bubble 5b712555651f6e68da73de59 color:green
SCRIPT445: Object doesn't support this action
rainbow-sdk.min.js (1,724847)
This line in rainbow-sdk.min.js
(r.readyState===XMLHttpRequest.DONE){var e=r.response,t=new File([e],i.replace(/^.*[\\\/]/,"")
I am executing this code:
-
Hi Esben,
Did you follow the following tutorial:
https://hub.openrainbow.com/#/documentation/doc/sdk/web/guides/5-Compatibility_with_IE11
Regards
-
Yes I have added:
I had to add:<!--polyfill is a dependency for IE11-->and//Fix for IE11if (!String.prototype.startsWith) {String.prototype.startsWith=function(searchString, position) {position=position||0;returnthis.indexOf(searchString, position) ===position;};}In order to get the Web SDK to work in IE11I can do all the following in IE11:- Create bubble
- Add members
- Send / receive IM
- Delete bubble
-
I don't think I have more than what I added to the first message:
Console log:
%c Mon Aug 13 2018 07:37:01 | RBW-SDK | StorageSrv | [addFileBub ] :: Try to add a file https://esben-lt:8010/images/Prisoners_dilemma_diagram.jpg to the bubble 5b712555651f6e68da73de59 color:green
SCRIPT445: Object doesn't support this action
rainbow-sdk.min.js (1,724847)
This line in rainbow-sdk.min.js
(r.readyState===XMLHttpRequest.DONE){var e=r.response,t=new File([e],i.replace(/^.*[\\\/]/,"")
-
Ok,
Unfortunately, IE11 doesn't support File creator ( see https://developer.mozilla.org/en-US/docs/Web/API/File ), instead using a file path or an URL in the uploadFileToBubble file parameter, use either a File object or a Blob with additional "name" member.
Regards
Vincent
-
Thanks Vincent,
I got the following to work if anyone else need an example:
function insertImage(ownedBubble){varxhr=newXMLHttpRequest();xhr.open("GET", "https://esben-lt:8010/images/Prisoners_dilemma_diagram.jpg");xhr.overrideMimeType("image/jpeg");xhr.responseType="blob";//force the HTTP response, response-type header to be blobxhr.onload=function() {varmyFile=blobToFile(xhr.response, "Prisoners_dilemma_diagram.jpg");rainbowSDK.fileStorage.uploadFileToBubble(ownedBubble, myFile, "Prisoner's dilemma diagram");}xhr.send();};functionblobToFile(theBlob, fileName){//A Blob() is almost a File() - it's just missing the two properties below which we will addtheBlob.lastModifiedDate=newDate();theBlob.name=fileName;returntheBlob;}Also add the following polyfill to eliminate findIndex error in IE11 after initialising the Web SDK//Fix for IE11 findIndexif (!Array.prototype.findIndex) {Object.defineProperty(Array.prototype, 'findIndex', {value: function(predicate) {if (this==null) {thrownewTypeError('"this" is null or not defined');}varo=Object(this);varlen=o.length>>>0;if (typeofpredicate!=='function') {thrownewTypeError('predicate must be a function');}varthisArg=arguments[1];vark=0;while (k<len) {varkValue=o[k];if (predicate.call(thisArg, kValue, k, o)) {returnk;}k++;}return-1;}});}Regards, Esben
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
7 Kommentare