ostrio: файлы & Метеор Удалить файл - PullRequest
0 голосов
/ 21 мая 2018

В настоящее время я использую ostrio: файлы для управления моей галереей изображений.Я не нашел документации о том, как удалять / удалять изображения, вставленные и загруженные программно.Вот официальная документация по атмосфере: https://atmospherejs.com/ostrio/files

У кого-нибудь есть идеи?

1 Ответ

0 голосов
/ 22 мая 2018

Документация по удалению файлов из коллекции:

https://github.com/VeliovGroup/Meteor-Files/wiki/remove

На этой странице: https://github.com/VeliovGroup/Meteor-Files/wiki/AWS-S3-Integration

Существует некоторый код для перехвата файлаудаление:

  // Intercept FilesCollection's remove method to remove file from AWS:S3
  const _origRemove = UserFiles.remove;
  UserFiles.remove = function (search) {
    const cursor = this.collection.find(search);
    cursor.forEach((fileRef) => {
      _.each(fileRef.versions, (vRef) => {
        if (vRef && vRef.meta && vRef.meta.pipePath) {
          // Remove the object from AWS:S3 first, then we will call the original FilesCollection remove
          s3.deleteObject({
            Bucket: s3Conf.bucket,
            Key: vRef.meta.pipePath,
          }, (error) => {
            bound(() => {
              if (error) {
                console.error(error);
              }
            });
          });
        }
      });
    });

    //remove original file from database
    _origRemove.call(this, search);
  };
} else {
  throw new Meteor.Error(401, 'Missing Meteor file settings');
}
...