Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { FilesCollection } from 'meteor/ostrio:files';
- Images = new FilesCollection({
- collectionName: 'Images',
- allowClientCode: false, // Disallow remove files from Client
- onBeforeUpload(file) {
- // Allow upload files under 10MB, and only in png/jpg/jpeg formats
- if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
- return true;
- } else {
- return 'Please upload image, with size equal or less than 10MB';
- }
- }
- });
- if (Meteor.isServer) {
- Meteor.publish('files.images.all', function () {
- return Images.find().cursor;
- });
- }
- Meteor.methods({
- 'RemoveFile'(uid) {
- Images.findOne({_id: uid}).remove((error) => {
- if(error){
- console.log();
- }
- }
- );
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement