Skip to content

Commit

Permalink
Step 21.20: Implement the upload method
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Dec 14, 2016
1 parent 780a906 commit aa6448c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions both/methods/images.methods.ts
@@ -0,0 +1,23 @@
import { UploadFS } from 'meteor/jalik:ufs';
import { ImagesStore } from '../collections/images.collection';

export function upload(data: File): Promise<any> {
return new Promise((resolve, reject) => {
// pick from an object only: name, type and size
const file = {
name: data.name,
type: data.type,
size: data.size,
};

const upload = new UploadFS.Uploader({
data,
file,
store: ImagesStore,
onError: reject,
onComplete: resolve
});

upload.start();
});
}

0 comments on commit aa6448c

Please sign in to comment.