2

i'm new to meteor. And i found that there are lost of option available for image storing. And finally i decided to use this package

CollectionFS. But in this package it stores file in collection. I do not want to store image in collection , i just want to upload it in my server folder.

Is it possible? How?

Thanks,

Hitesh S
  • 460
  • 1
  • 5
  • 20

1 Answers1

1

You are in luck, this is possible! Please refer to the documentation:

https://github.com/CollectionFS/Meteor-CollectionFS

In the Storage Adapter section is refers to cfs:filesystem. This allows you to save to the servers filesystem rather than a collection via GridFS. The Adapter and its documentation can be found here:

https://github.com/CollectionFS/Meteor-CollectionFS/tree/devel/packages/filesystem

The implementation is fairly straight forward with the documentation.

As it points out in the documentation, you can add something like this to your common.js file:

var Images = new FS.Collection("images", {
    stores: [new FS.Store.FileSystem("images", {path: "~/uploads"})]
});

This creates an FS.Collection called images which stores the images to a folded called uploads in your project and creates a collection to tie those uploads to. Structucing your project is a bit outside of the scope of your question, but you can get more information about that here:

http://docs.meteor.com/#/full/structuringyourapp

Tim C
  • 1,934
  • 12
  • 25
  • for the filesystem they have given Uses but they do not specify where to write this code. Could you please help? – Hitesh S May 08 '15 at 05:47
  • ok, i have created common.js , can it be written in my upload button event? 'click #uploadTest':function(){} – Hitesh S May 08 '15 at 06:29
  • Yes :) check the documentation for "Initiate the Upload" and it should show you how. – Tim C May 08 '15 at 06:31
  • i have written this code in my button click event var file = $('#testImage').get(0).files[0]; var Images = new FS.Collection("images", { stores: [new FS.Store.FileSystem("images", {path: "myphotos"})] }); code doesn't give error and creates folder myphotos but there is no images in this folder, can you help? – Hitesh S May 08 '15 at 06:52