From 40b5d21a90cfedd2dfedb46b0877196224523147 Mon Sep 17 00:00:00 2001 From: jame Date: Wed, 15 Jul 2015 03:12:46 -0500 Subject: [PATCH] adds logic to load uploaded image to filepicker as a base64 image string #49 --- .../admin/artist/images/new/controller.js | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/client/app/pods/admin/artist/images/new/controller.js b/client/app/pods/admin/artist/images/new/controller.js index 9428e29..695f7db 100644 --- a/client/app/pods/admin/artist/images/new/controller.js +++ b/client/app/pods/admin/artist/images/new/controller.js @@ -13,9 +13,30 @@ export default Ember.ObjectController.extend({ }, fileSelected: function(data) { var self = this; + data.forEach(function (upload){ - let image = self.store.createRecord('image', { artist: self.get('model')}); - image.set('path', upload.url); + + //get a filepicker instance here. + filepicker.read(upload, {base64encode: true}, + function(data) { + "use strict"; + //console.log(data); + let image = self.store.createRecord('image', { artist: self.get('model')}); + image.set('path', 'data:image/jpeg;base64,' + data); + image.save(); + }, + function(err) { + "use strict"; + console.error(err); + }, + function(progressPercent) { + "use strict"; + //console.log(progressPercent); + } + ); + + //let image = self.store.createRecord('image', { artist: self.get('model')}); + //image.set('path', upload.url); }); this.send('hidePicker'); },