• Pavel Navratil
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Mr.


  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi,
I'm working on a custom picture resize before uploading to Salesforce. I'm receiving an error after update od Sprint 19. 
error message
The issue is in this line:
img.src = _URL.createObjectURL(file);
Not sure exactly where is an issue.

The whole code is here:
var _URL = window.URL;
        var img = new Image(),
        resizeWidth = 2000,
        quality = 0.5;
        img.src = _URL.createObjectURL(file);
        img.onload = function () {
            var cvs = document.createElement('canvas');
            var resizeRatio = img.width / resizeWidth;
            cvs.width = img.width / resizeRatio;
            cvs.height = img.height / resizeRatio;
            var ctx = cvs.getContext("2d").drawImage(img, 0, 0, (img.width), (img.height), 0, 0, (img.width / resizeRatio), (img.height / resizeRatio));
            var newImageData = cvs.toDataURL('image/jpeg', quality);
            var base64 = 'base64,';
            var dataStart = newImageData.indexOf(base64) + base64.length;
            var fileContents = newImageData.substring(dataStart);
            self.uploadProcess(component, file, fileContents);
        }
Thank you for help.
Hi,
I'm working on a custom picture resize before uploading to Salesforce. I'm receiving an error after update od Sprint 19. 
error message
The issue is in this line:
img.src = _URL.createObjectURL(file);
Not sure exactly where is an issue.

The whole code is here:
var _URL = window.URL;
        var img = new Image(),
        resizeWidth = 2000,
        quality = 0.5;
        img.src = _URL.createObjectURL(file);
        img.onload = function () {
            var cvs = document.createElement('canvas');
            var resizeRatio = img.width / resizeWidth;
            cvs.width = img.width / resizeRatio;
            cvs.height = img.height / resizeRatio;
            var ctx = cvs.getContext("2d").drawImage(img, 0, 0, (img.width), (img.height), 0, 0, (img.width / resizeRatio), (img.height / resizeRatio));
            var newImageData = cvs.toDataURL('image/jpeg', quality);
            var base64 = 'base64,';
            var dataStart = newImageData.indexOf(base64) + base64.length;
            var fileContents = newImageData.substring(dataStart);
            self.uploadProcess(component, file, fileContents);
        }
Thank you for help.