5

Html:

<div
  ngf-select
  ngf-keep="true"
  ng-model="vm.photos"
  ngf-accept="'image/*'"
  ngf-pattern="'image/*'"
  ngf-multiple="true">
  Select
</div>
<button ng-click="vm.uploadPhotos()">Upload</button>

Client JS:

vm.uploadPhotos = function() {
  _.forEach(vm.photos, function(photo) {
      PhotoCol.insert(photo);
  });
};

Server JS:

PhotoCol = new FS.Collection('propertyPhoto', {
  stores: [
    new FS.Store.FileSystem('original')
  ],
  filter: {
    allow: {
      contentTypes: ['image/*']
    }
  }
});

PhotoCol.allow({
  insert: function() {
    return true;
  },
  update: function() {
    return true;
  },
  remove: function() {
    return true;
  },
  download: function() {
    return true;
  }
});

When the upload starts, I need a way to cancel one or all upload processes. And CollectionFS make a record in the DB before the upload is done, so if for some reason the user terminated the browser before completing the upload process then I'll have an entry for photo without an uploaded file. Here I need to catch that error to remove the entry from the DB. Any ideas?

Raeef Refai
  • 1,325
  • 12
  • 24

0 Answers0