I am using Meteor CollectionFS. Currently my file uploading is performed on client. I want to perform file uploading on server so that other platforms like andriod or ios can use my services of file uploading.
Currently 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 see everything is done in the client controller. How can I perform this on server controllers in Meteor?
How can I send my file to the server so that I can process, insert or upload my images there?
EDIT
As you know that an Android App will be sending a base64 encoded string. So how will I treat that here? I want to have a centralized function for Image Uploading on Meteor Server.