Upload image example not working in meteor kitchen


#1

Hi Team,

I’m new in meteor app development and using Meteor kitchen to create web app. I want to implement file upload functionality but example given in meteor kitchen is not working as well as my code.

Please find attached JSON:

{ "application": { "collections": [ { "name": "myImages", "type": "file_collection", "storage_adapters": [ "filesystem" ], "roles_allowed_to_insert": [ "user", "admin" ], "roles_allowed_to_update": [ "user", "admin" ], "roles_allowed_to_delete": [ "user", "admin" ] }, { "name": "gallery", "type": "collection", "fields": [ { "name": "title", "title": "Title", "required": true, "type": "string" }, { "name": "myImageId", "title": "File", "input": "file", "file_collection": "myImages", "file_container": "fileObject", "type": "string" } ] } ], "queries": [ { "name": "gallery", "collection": "gallery" }, { "name": "gallery_empty", "collection": "gallery", "filter": { "_id": null }, "find_one": true } ], "free_zone": { "pages": [ { "name": "home", "components": [ { "name": "gallery", "title": "Example Gallery", "type": "custom_component", "query_name": "gallery", "html": "<template name=\"TEMPLATE_NAME\">\n\t<h2>\n\t\tCOMPONENT_TITLE\n\t\t<button type=\"button\" class=\"btn btn-success pull-right new-file\">\n\t\t\t<span class=\"fa fa-plus\">\n\t\t\t</span>\n\t\t\tAdd file\n\t\t</button>\n\t</h2>\n\n\t<p>\n\t\tThis example application is built with <a href=\"http://www.meteorkitchen.com\">Meteor Kitchen</a> - code generator for Meteor.js.\n\t\tSource code is <a href=\"https://github.com/perak/kitchen-examples/tree/master/example-upload\" target=\"_blank\">here</a>\n\t</p>\n\n\t<hr />\n\n\t{{#if QUERY_NAME}}\n\t\t<div class=\"row\">\n\t\t\t{{#each QUERY_NAME}}\n\t\t\t\t<div class=\"col-xs-12 col-sm-4 col-md-3\" style=\"padding: 10px;\">\n\t\t\t\t\t<h4>\n\t\t\t\t\t\t<a href=\"#\" class=\"delete-file pull-right\"><span class=\"fa fa-close\"></span></a>\n\t\t\t\t\t\t{{title}}\n\t\t\t\t\t</h4>\n\t\t\t\t\t{{#with file}}\n\t\t\t\t\t\t{{#if isImage}}\n\t\t\t\t\t\t\t<a href=\"{{url}}\" target=\"_blank\"><img src=\"{{url}}\" width=\"100%\"></a>\n\t\t\t\t\t\t{{/if}}\n\n\t\t\t\t\t\t{{#if isAudio}}\n\t\t\t\t\t\t\t<audio src=\"{{url}}\" width=\"100%\" controls=\"controls\"></audio>\n\t\t\t\t\t\t{{/if}}\n\n\t\t\t\t\t\t{{#if isVideo}}\n\t\t\t\t\t\t\t<video src=\"{{url}}\" width=\"100%\" controls=\"controls\"></video>\n\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t{{/with}}\n\t\t\t\t</div>\n\t\t\t{{/each}}\n\t\t</div>\n\t{{else}}\n\t\t<div class=\"alert alert-info\">Gallery is empty :(</div>\n\t{{/if}}\n\n</template>", "js": "Template.TEMPLATE_NAME.events({\n\t\"click .new-file\": function(e, t) {\n\t\tRouter.go(\"PAGE_ROUTE_NAME.insert\");\n\t},\n\n\t\"click .delete-file\": function(e, t) {\n\t\te.preventDefault();\n\t\tvar self = this;\n\t\tbootbox.dialog({\n\t\t\tmessage: \"Delete item?\",\n\t\t\ttitle: \"Delete\",\n\t\t\tanimate: false,\n\t\t\tbuttons: {\n\t\t\t\tsuccess: {\n\t\t\t\t\tlabel: \"Yes\",\n\t\t\t\t\tclassName: \"btn-success\",\n\t\t\t\t\tcallback: function() {\n\t\t\t\t\t\tCOLLECTION_VAR.remove({ _id: self._id });\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdanger: {\n\t\t\t\t\tlabel: \"No\",\n\t\t\t\t\tclassName: \"btn-default\"\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn false;\n\t}\n});\n\nTemplate.TEMPLATE_NAME.helpers({\n});" } ], "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" } ], "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": { "meteor": [ "cfs:gridfs" ] } } }

Regards,
Pooja