perak / kitchen-site

Meteor Kitchen site source code
MIT License
282 stars 38 forks source link

Specifying storage adapter filesystem results in gridfs #213

Open bartuelen opened 8 years ago

bartuelen commented 8 years ago

Error generating storage_adapter code

In Meteor Kitchen when specifying a collection named "files" of type = "file_collection" with storage_adapter = "filesystem" the downloaded JSON-file still contains the right specification, storage_adapter is "filesystem", but when generating the meteor code using meteor-kitchen locally the code in the "files.js" shows:

this.Files = new FS.Collection("files", { stores: [new FS.Store.GridFS("files")] });

This is not a filesystem but gridfs definition.

Below the correct solution (based on the example at https://github.com/CollectionFS/Meteor-CollectionFS#creat-the-fs-collection-and-filestore ) Note: When no upload path is defined, it defaults to the "cfs/files" upload directory.

this.Files = new FS.Collection("files", { // stores: [new FS.Store.GridFS("files")] <== This is generated by MK and is wrong. Should be next line. stores: [new FS.Store.FileSystem("files")] // The corrected statement that works fine. });

After applying the correct code, the application works fine and stores uploaded files and images in the cfs/files directory.

Is there something I forget to specify in the json-file at meteorkitchen.com ?

The full json is included below. It is based on the example-upload with minor changes to some extra fields and, of course, the storage_adapter.

Greetz, Bart Uelen

{ "application": { "collections": [ { "name": "files", "type": "file_collection", "storage_adapters": [ "filesystem" ] }, { "name": "gallery", "type": "collection", "fields": [ { "name": "title", "title": "Title", "required": true, "type": "string" }, { "name": "fileId", "title": "File", "input": "file", "file_collection": "files", "file_container": "file", "type": "string" }, { "name": "hyperlink", "title": "Hyperlink", "type": "string" }, { "name": "sequence", "title": "Sequence", "required": true, "type": "integer", "default": "0" } ] } ], "queries": [ { "name": "gallery", "collection": "gallery", "options": { "sort": [ "sequence" ] } }, { "name": "gallery_empty", "collection": "gallery", "filter": { "_id": null }, "find_one": true }, { "name": "gallery_edit", "collection": "gallery", "find_one": true, "filter": { "_id": ":galleryId" } } ], "free_zone": { "pages": [ { "name": "home", "components": [ { "name": "gallery", "title": "Example Gallery", "type": "custom_component", "custom_template": "client/views/files/gallery", "query_name": "gallery" } ], "pages": [ { "name": "insert", "components": [ { "name": "form", "title": "Add new file", "type": "form", "mode": "insert", "query_name": "gallery_empty", "submit_route": "home", "cancel_route": "home" } ], "type": "page" } ], "type": "page" }, { "name": "gallery_edit_page", "query_name": "gallery_edit", "route_params": [ "galleryId" ], "close_route": "home", "back_route": "home", "type": "page", "components": [ { "name": "gallery_edit_form", "query_name": "gallery_edit", "mode": "update", "submit_route": "home", "cancel_route": "home", "back_route": "home", "type": "form" } ] } ], "components": [ { "name": "main_menu", "type": "menu", "class": "nav navbar-nav", "items": [ { "title": "Example gallery", "route": "home", "icon_class": "fa fa-home" } ] } ], "type": "zone" }, "public_zone": { "type": "zone" }, "private_zone": { "type": "zone" }, "packages": {}, "title": "Upload to filesystem" } }

perak commented 8 years ago

Hi @bartuelen

everything is ok with your code - that is bug in the kitchen.

Thanks for bug-catch and solution, I'll try to implement it next week (sorry, I cannot do it promptly)

:+1:

perak commented 8 years ago

@bartuelen fixed in v0.9.55, will be uploaded later today.

perak commented 8 years ago

Hi @bartuelen fixed and uploaded, please check it out and close this issue if it worked. :+1:

bartuelen commented 8 years ago

Petar,

Thanx.

I'm testing it right now for a small new app called 33rpm.

33rpm? Yes that is old, indeed!

About some old vinyl recordings I am converting them into MP3 and put them in the app. Songs from the '70 and early '80 from last century. Getting entimental ... :-)

Just curious if I will store them plainly into a MongoDB collection or in external FSfilesystem store. I'll experiment and see what is best, depending on size and playback behaviour.

To be cont'd ...

Greetz,

Bart

Petar Korponaić schreef op 2016-01-18 20:54:

Hi @bartuelen [1] fixed and uploaded, please check it out and close this issue if it worked.

Reply to this email directly or view it on GitHub [2].

*

Links:

[1] https://github.com/bartuelen [2] https://github.com/perak/kitchen-site/issues/213#issuecomment-172634393

perak commented 8 years ago

@bartuelen wow! 33rpm vinyls - that's super cool! :D

BTW, if you store directly to mongo collection, you are limited to 16mb per document. And it quickly complains on memory limit if you have bunch of documents and try to sort them. That's why I think storing binary files inside regular mongo collection is not very good idea.

Also, there is super-simple way to upload files: https://www.filestack.com but it's not free (actually 250 file uploads per month is free). It works client-side only, shows their built-in popup window for upload, and when file is uploaded it is sent to their server at random URL. Your application receives the URL and stores URL into database. Simple like that (but unfortunately - not free).