Im trying to add photo uploading to individual accounts that are already set up in a collection in Kinvey. I've been messing around with it most of the day and can't figure it out. Anyone have any suggestions on how I should set this up? thanks!
Edit:
So i looked into how to do it more and Kinvey says to structure it like so: var fileContent = 'file-content-string';
var promise = $kinvey.File.upload(fileContent, {
_id : 'my-file-id',
_filename : 'my-file.txt',
mimeType : 'text/plain',
size : fileContent.length
});
however I am unclear how to implement that into my angular code. I am using ng-file-upload so my angular code should look something like this:
var MyCtrl = [ '$scope', '$upload', function($scope, $upload) {
$scope.onFileSelect = function($files) {
//$files: an array of files selected, each file has name, size, and type.
for (var i = 0; i < $files.length; i++) {
var file = $files[i];
$scope.upload = $upload.upload({
url: 'server/upload/url', //upload.php script, node.js route, or servlet url
data: {myObj: $scope.myModelObj},
file: file,
}).progress(function(evt) {
console.log('percent: ' + parseInt(100.0 * evt.loaded / evt.total));
}).success(function(data, status, headers, config) {
// file is uploaded successfully
console.log(data);
});
}
};
}];
How how can I combine these to make it work? thanks.