I am trying to upload a file in loopback server. It is being uploaded successfully. All the properties of file are read-only, but i want value of name property to be updated (with new value) before save. These are the property of file when opened.
Following is a function to which I am sending array of all opened files to be saved (after opening all the files).
fileUpload.post = function (files) {
for (var i = 0; i < files.length; i++) {
if (angular.isDefined(files[i])) {
files[i].upload = Upload.upload({
url: "http://localhost:3000/api/Containers/files/upload",
data: {
file: files[i]
}
});
}
}
}
In server models folder, I have a model called container. Trying to work with beforeRemote function in container.js. But don't know what to write inside it. I think i should write something inside it to change value of name property.
What should I do?
module.exports = function (Container) {
var fs = require('fs');
Container.beforeRemote('upload', function(context, user, next) {
});
Container.afterRemote('upload', function(context,user,next) {
});
};
via Umair Jameel
No comments:
Post a Comment