Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to resolve when copy file finished? #133

Open
whitesnow9291 opened this issue Sep 19, 2017 · 0 comments
Open

How to resolve when copy file finished? #133

whitesnow9291 opened this issue Sep 19, 2017 · 0 comments

Comments

@whitesnow9291
Copy link

whitesnow9291 commented Sep 19, 2017

How are you.
I am uploading image and copy it to thumbnails holder.
I added thumbnail url to main image collection so that I can load thumbnail instead of big img.
Now it working correctly, it upload main image and copy to thumbnail holder, and set thumbnail url to image collection correctly.
But it always return image collection without thumbnail url field.
This is what I have done. I run this function to upload image and copy it to thumbnail holder

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 .  // here! when completed it returns image collection without thumb url
                                        // but if check db, it saves thumb url correctly.
});

upload.start();

});

And this is the main uploading and copy part.

const Thumbnail320Store = new UploadFS.store.Local({
...
onFinishUpload(file) {
Images.update({_id: file.originalId}, {$set: {thumb320Url: file.url}});
},
...
});
ImagesStore = new UploadFS.store.Local({
...
copyTo: [
Thumbnail320Store
],
...
});

Thanks

@whitesnow9291 whitesnow9291 changed the title How to resolve when copyfile finished? How to resolve when copy file finished? Sep 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant