I am using Meteor CollectionFS. Currently, my file upload is done on the client. I want to upload files on a server so that other platforms such as andriod or ios can use my file upload services.
Now here is my code:
client.html
<input type="file" custom-on-change="uploadFile">
clientController.js
app.controller('clientController', function ($scope, $meteor, $filter) { $scope.uploadFile = function(event){ var files = event.target.files; for (var i = 0, ln = files.length; i < ln; i++) { files[i].userId = Meteor.userId(); Images.insert(files[i], function (err, fileObj) { }); } }; }); app.directive('customOnChange', function() { return { restrict: 'A', link: function (scope, element, attrs) { var onChangeHandler = scope.$eval(attrs.customOnChange); element.bind('change', onChangeHandler); } }; });
Schema.js
Images = new FS.Collection("images", { stores: [ new FS.Store.FileSystem("images", {path: '~/uploads'}) ] });
The code works perfect for me. But, as you can see, everything is done in the client controller. How can I do this on server controllers in Meteor?
How to send a file to the server so that I can process, insert or upload my images there?
EDIT
As you know, an Android app will send a base64 encoded string. So how will I relate to this here? I want to have a centralized function for uploading images to Meteor Server.
source share