【发布时间】:2014-06-04 12:30:16
【问题描述】:
我正在使用科尔多瓦 3.4。当我捕获图像并设置它时,它工作正常但是当我尝试从画廊访问图像时,我得到了 url
content://com.android.providers.media.documents/document/image%4A463
我的图像标签中出现图像加载错误。我知道这是一个已知的错误,我参考了堆栈问题,例如Unable to load image when selected from the gallery on Android 4.4 (KitKat) using PhoneGap Camera Plugin
我不能使用提到的手动设置 URI 的粗略工作,例如 content://media/external/images/media/,因为我们专注于具有内部内置存储的设备,例如 Moto
您还可以确认此问题已在 cordova 3.5 中得到修复。因为我需要我的官员的许可才能下载,我必须确保它是可以实现的。有人可以帮忙
更新:
app.directive('upload', function() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
elm.on('click', function() {
navigator.camera.getPicture(
function(imageURI) {
scope.$apply(function() {
alert(imageURI);
ctrl.$setViewValue(imageURI);
});
window.resolveLocalFileSystemURI(imageURI, function(fileEntry) {
// ctrl.$setViewValue(imageURI);
alert("inside local file" + imageURI);
alert("Inside local file system");
fileEntry.file(function(fileObj) {
alert("hai");
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileObj.name;
options.mimeType = fileObj.type;
var ft = new FileTransfer();
// var url = fileUploadUrl;
// ft.upload(imageUri, encodeURI(url), success, failure, options);
});
});
},
function(err) {
ctrl.$setValidity('error', false);
}, {quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY
}
);
});
}
};
});
我的 HTML:
<img
ng-src="{{onepic}}"
width="250"
height="390"
alt="error"/>
我在 watch 函数中的控制器中为 onepic 设置了值。因此,当指令返回一个 URI 时,它将自动在 onepic 中设置。请指定任何替代解决方案,或者如果我做错了什么,我是 angularjs 的新手
【问题讨论】:
标签: android image cordova cordova-3 cordova-plugins