UploadFS copyTo file not found

I had to switch from
CollectionFS https://github.com/CollectionFS/Meteor-CollectionFS
to
UploadFS https://github.com/jalik/jalik-ufs
due to cfs being depricated and wasn’t working anymore under meteor 1.4

I’m using the gridFS addon. Saving one file to store works like a charm but the copyTo option errors with
(STDERR) ufs: cannot copy file "4Ra9AM3fkaCCWAgzj" (File does not exist)

My collection uploadfs.files has an entry

96 {9}
_id : 4Ra9AM3fkaCCWAgzj
filename : 4Ra9AM3fkaCCWAgzj
contentType : image/png
length : 32358
chunkSize : 261120
uploadDate : 2016-08-10 12:12:56
aliases : null
metadata : null
md5 : 1592f38d5e1f8da15783b899d6c72305

Meteor.photos = new Mongo.Collection('photos')
Meteor.thumbnails128 = new Mongo.Collection('thumbnails-128')
Meteor.thumbnails64 = new Mongo.Collection('thumbnails-64')

// Activate simulation for slowing file reading
UploadFS.config.simulateReadDelay = 1000; // 1 sec

// Activate simulation for slowing file uploading
UploadFS.config.simulateUploadSpeed = 128000; // 128kb/s

// Activate simulation for slowing file writing
UploadFS.config.simulateWriteDelay = 2000; // 2 sec

Meteor.thumbnail128Store = new UploadFS.store.GridFS({
  collection: Meteor.thumbnails128,
  name: 'thumbnails-128',
  chunkSize: 1024 * 255,
  transformWrite: function(readStream, writeStream, fileId, file) {
    let gm = Npm.require('gm')
    if (gm) {
      gm(readStream)
        .resize(128, 128)
        .gravity('Center')
        .extent(128, 128)
        .quality(75)
        .stream().pipe(writeStream)
    } else {
      console.error("gm is not available", file)
    }
  }
})

Meteor.thumbnail64Store = new UploadFS.store.GridFS({
  collection: Meteor.thumbnails64,
  name: 'thumbnails-64',
  chunkSize: 1024 * 255,
  transformWrite: function(readStream, writeStream, fileId, file) {
    let gm = Npm.require('gm')
    if (gm) {
      gm(readStream)
        .resize(64, 64)
        .gravity('Center')
        .extent(64, 64)
        .quality(75)
        .stream().pipe(writeStream)
    } else {
      console.error("gm is not available", file)
    }
  }
})

Meteor.photosStore = new UploadFS.store.GridFS({
  collection: Meteor.photos,
  name: 'photos',
  chunkSize: 1024 * 255,
  // Apply a filter to restrict file upload
  filter: new UploadFS.Filter({
    minSize: 1,
    maxSize: 1024 * 1000, // 1MB,
    contentTypes: ['image/*']
  }),
  copyTo: [
    Meteor.thumbnail128Store,
    Meteor.thumbnail64Store
  ]
})

What did I miss? it does work with the local addon

1 Like

I’m having the exact same problem. For me it works great when I run the app on my local machine (Mac). However, when I run the app on a remote Linux server, I get the same error message. Looking at the UFS code it looks like it can find the original file but is indeed choking when trying to make the copy.

Does anyone have any thoughts on this issue?

Casey

Please issue that to the developer on github. He can’t reproduce it. And I’m currently unable to give further details on why it’s not working. We don’t have a live system yet. So there is that
I ended up removing copyTo and use currently the fullsize images. It works but I want that thumbnail feature so badly.