我正在使用phonegap API使用以下指令拍照(或从库中选择):
MyApp.directive('Camera', function () {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
elm.bind('click', function() {
navigator.camera.getPicture(function (imageURI)
{
scope.$apply(function() {
ctrl.$setViewValue(imageURI);
});
}, function (err) {
ctrl.$setValidity('error', false);
},
//Options => http://docs.phonegap.com/en/2.6.0/cordova_camera_camera.md.html#Camera
{ quality: 50,
destinationType:Camera.DestinationType.FILE_URI
})
});
}
};
});
它返回给我一个 URI,看起来像使用 Chrome 上的波纹模拟器,我可以看到粘贴了这个 URI。
blob:http%3A//localhost%3A8080/8e18de30-d049-4ce2-ae88-8500b444581e
我的问题是加载此 URI
$scope.updateUserProfile = function (user) {
var myPicfile = $http.get(user.myPicture);
dataService.uploadPicture . . . some code to update the picture to Parse
}
*Note: 我无法将phonegap filetransfer 与parse.com 一起使用:
当我这样做时,我得到:
我的要求如下:
uploadPicture:函数uploadPicture(用户,回调)
{
var 服务器地址 = 'https://api.parse.com/1/files/' + 用户.尼克 ;
$http({
method: 'POST',
url: serverUrl,
data: user.myPicture,
headers: {'X-Parse-Application-Id': PARSE_APP_ID,
'X-Parse-REST-API-Key': PARSE_REST_API_KEY,
'Content-Type': 'text/plain'
}
})
关于如何将图像内容保存到文件中,然后我可以愉快地上传到 Parse.com,有什么想法吗?
Thanks!