Wednesday, June 7, 2017

JavaScript code to show image from raw image content bytes (blob)

<div> <img id="attachmentImage" /> </div> // attachmentCntnt : this variable contains raw bytes array of the attachment image // attachmentType : keeps the image type such as jpg/jpeg/png/... // _.defer and _.isNull are methods from underscore.js library var imageUrl = null; var attachmentCntntU8Ary = new Uint8Array(attachmentCntnt); var blob = new Blob([attachmentCntntU8Ary], { type: "image/" + attachmentType }); var urlCreator = window.URL || window.webkitURL; imageUrl = urlCreator.createObjectURL(blob); _.defer(function (t) { if (!_.isNull(imageUrl)) { var img = document.querySelector("#attachmentImage"); img.src = imageUrl; }; }, self);

Share/Bookmark

Sunday, June 4, 2017

Angular 4.0 + Angularfire 2 Ver 4.0 RC2 :: ERROR in ./~/firebase/app/shared_promise.js

"dependencies": { "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", "angularfire2": "^4.0.0-rc.0", "core-js": "^2.4.1", "firebase": "^4.0.0", "rxjs": "^5.1.0", "zone.js": "^0.8.4" },

Angular 4.0 + Angularfire 2 Ver 4.0 RC2 :: ERROR in ./~/firebase/app/shared_promise.js promise-polyfill It's about missing dependenciy which could be fixed by installing promise-polyfill by npm.
npm install promise-polyfill --save-exact

Share/Bookmark