Created
September 20, 2016 13:50
-
-
Save brunohaveroth/506e17430a027300886e7f44e2f7f1bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
navigator.camera.getPicture((data)=> { | |
var byteCharacters = atob(data); | |
var byteNumbers = new Array(byteCharacters.length); | |
for (var i = 0; i < byteCharacters.length; i++) { | |
byteNumbers[i] = byteCharacters.charCodeAt(i); | |
} | |
var byteArray = new Uint8Array(byteNumbers); | |
var blob = new Blob([byteArray], {type: 'image/jpg'}); | |
var form = new FormData(); | |
form.append("product-image", blob); | |
this.set('uploadForm', form); | |
this.renderPreview(blob); | |
}, function() { | |
alert('Falha ao escolher a imagem'); | |
}, { | |
quality: 50, | |
destinationType: Camera.DestinationType.DATA_URL | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment