通过离子

时间:2016-09-08 08:05:04

标签: angularjs cordova ionic-framework cordova-plugins

我有这个工厂用Cordova File Transfer插件管理上传文件:

app.factory('Camera', function($q) {

var url = "http://www.myurl.com";

return {
   uploadPicture: function (imgURI, fileName) {
        var q = $q.defer();

        function win(r) {
            q.resolve(r.response);
        }

        function fail(e) {
            q.reject(e);
        }

        var options = {
            fileKey: "file",
            fileName: fileName,
            chunkedMode: false,
            mimeType: "image/jpg"
        };

        var ft = new FileTransfer();
        ft.upload(imgURI, url, win, fail, options);
        return q.promise;
    }
  }
});

从我的控制器我这样使用它:

 Camera.uploadPicture(imagePath, fileName).then(function (res) {
           //Some code

        }), function (err) {
           //Some code
        }

我想从工厂取回onprogress事件,以在视图中显示上传的进度。有办法吗?

0 个答案:

没有答案