Closed Nico-L closed 8 years ago
Hi @Nico-L , Great question.
The data-flow of subversions:
[user uploads the file] -> [server receives the file] -> [file processing (creating subversion) on the server] -> [adding subversion data into versions
object]
As you see subversion can be managed/added on the server side. If I'm got you correctly you're cropping the file on the Client, it's a bit different, as you will need to upload cropped version again. Isn't better to load file into browser, crop it and then upload to server?
The advantage of uploading the original, then cropping subversions is the possibility to make different cropping afterwards. Is it important? will it be even used? Probably not!
So your proposed way will be better.
So to make my mind clearer. The crop will be declined in different thumbnailed subversions as in your example. In that case, Meteor-Files will create one or several thumbnails with the onAfterUpload
event added to different subversions. Does the module save a different file for each thumbnail?
I am not sure as I hardly read Coffeescript, so your example is a bit criptic for me. This would need an image manipulation package, this should be the gm function from the cfs:graphicsmagick package, right?
The advantage of uploading the original, then cropping subversions is the possibility to make different cropping afterwards. Is it important? will it be even used? Probably not!
Not sure if I got you right, but you store original file, and do whatever you need with it, crop, rotate, resize, then just add all modifications (subversions) into versions
object
So to make my mind clearer. The crop will be declined in different thumbnailed subversions as in your example. In that case, Meteor-Files will create one or several thumbnails with the onAfterUpload event added to different subversions. Does the module save a different file for each thumbnail?
Nope, onAfterUpload
returns you an Object saved to Collection with data about received file. Then you're free to do what ever you want with it, like use gm
to create thumbs, or ffmpeg
to convert video to different formats. All you need after file processing is add subversion's info into versions
object.
I am not sure as I hardly read Coffeescript, so your example is a bit criptic for me. This would need an image manipulation package, this should be the gm function from the cfs:graphicsmagick package, right?
cfs:graphicsmagick
is used in example, but you're free to use any lib you want.
Nope, onAfterUpload returns you an Object saved to Collection with data about received file. Then you're free to do what ever you want with it, like use gm to create thumbs, or ffmpeg to convert video to different formats. All you need after file processing is add subversion's info into versions object.
I am not sure to get you right. onAfterUpload let me create thumbs and add subversion info to versions object. OK. Then I have to save the different thumbs by myself or does Meteor-Files take care of this during the onAfterUpload events?
You do it yourself via FilesCollection#collection.update()
method
See an example
This is where I got lost in coffeescript. If I understand correctly: for each size:
The thing I don't get: when is the new thumb file saved on the filesystem? During the gm manipulation? During the FilesCollection#collection.update()
?
Thanks @dr-dimitru,
I must have a closer look. For the moment, I close the issue. Maybe i'd return for further questions if needed, but it is much clearer now.
Meteor-Files seems perfect for my project, with the right amount of features.
Hi @dr-dimitru,
I have a question about the creation of subversion. I am using meteor-files to upload images (as first application. It will handle all file manipulation at the end).
The idea is to allow the user to insert images the the files collection and then crop them with react-cropperjs package as subversion. The crop issues a blob that I transforms into a file.
Then I creation a new subversion entry (this is ugly react code, I'll fiw that when I got a good understanding of what is going on:
newVersion.call is a meteor call where I update the collection:
Problem: the file has no path as the saving in the file system is not handle. Do I have to handle the save through fs-extra, get the path and then update the image.versions?
Is it the right way to perform this or is there a Meteor-files command able to handle the whole process?
Thanks