Start a new topic

File upload in angular to kinvey collection


I am working on getting images uploaded to an existing kinvey collection but am having a ton of trouble getting kinvey to play nice with ng-file-upload.

ng-file-upload uses this:



angular.module('myApp', ['angularFileUpload']);

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
var $file = $files[i];


url: 'my/upload/url',

file: $file,

progress: function(e){}

}).then(function(data, status, headers, config) {

// file is uploaded successfully






and I am struggling with getting the kinvey upload to work with it. I have it working for a php server but that doesn't help me. Can someone show me how to implement kinvey in this?


so far this is what i have:

var promise = $kinvey.File.upload(files[0].file,{

_filename: files[0],

public: true,

size: files[0].file.size,

mimeType: files[0].file.type

}).then(function (_result) {

console.log("$upload: " + JSON.stringify(_result));


}, function error(err) {

console.log('[$upload] received error: ' + JSON.stringify(err));


return promise;

Are you getting either of the console.logs in your second post example? If not, can you try adding another error callback to the returned promise?

A working example on something like for the AngularJS bit would be helpful, or at least something more complete posted here that shows your AngularJS code together with Kinvey code?

for how I currently have it set up to save the url to the kinvey collection because I cant figure out image uploads.

Instead of a text input box I want to be able to select an image to upload.
I’ve created a small snippet [here]( It uploads an image successfully. Please make sure you use the [File Upload plugin](
Login or Signup to post a comment