Skip to content

Instantly share code, notes, and snippets.

@mcfiredrill
Created August 24, 2018 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcfiredrill/28e9e3fddf44dd6eecdfa6a80fb023dc to your computer and use it in GitHub Desktop.
Save mcfiredrill/28e9e3fddf44dd6eecdfa6a80fb023dc to your computer and use it in GitHub Desktop.
saveImage(signedId){
let image;
const finishSavingImage = (upload) => {
image = this.get('store').createRecord('image', { upload: upload });
this.set(image, 'file', signedId);
image.save().then(() => {
upload.get('images').pushObject(image);
this.set('upload', upload);
});
};
if(!this.get('upload')){
const upload = this.store.createRecord('upload');
upload.save().then(() => {
finishSavingImage(upload);
});
}else{
const upload = this.get('upload');
finishSavingImage(upload);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment