갤러리에서 가져온 이미지를 아래 코드로 업로드하려고합니다.Android의 갤러리에서 이미지를 업로드 할 수 없습니다. 4.4
//imageUri is a uri which is gotten by Phonegap camera API
//(use option Camera.PictureSourceType.PHOTOLIBRARY&&Camera.DestinationType.FILE_URI)
var imageUri = getImageUri();
//handlerUri is a uri to upload the image
var handlerUri = getHandlerUri();
window.resolveLocalFileSystemURI(imageUri, function(fileEntry) {
fileEntry.file(function(fileObj) {
var fileName = fileEntry.name;
var options = new FileUploadOptions();
options.headers = {
Connection: "close"
};
options.fileKey = "uploadfiles";
if (fileName.indexOf('/') > -1) {
options.fileName = fileName.substr(fileName.lastIndexOf('/') + 1);
} else {
options.fileName = fileName;
}
options.mimeType = "image/jpeg";
options.chunkedMode = false;
options.params = params;
var ft = new FileTransfer();
imageUri = fileEntry.nativeURL;
ft.upload(imageUri, handlerUri,
function(r) {
if (r.response == "success") {
} else {
}
},
function(error) {},
options, true);
}, function(error) {
});
}, function(error) {
});
Android 4.4 미만의 기기의 경우 앱이 잘 작동합니다. 그러나 Android 4.4 KitKat에서는 동일한 코드가 더 이상 작동하지 않습니다.
참고 : 장시간 업로드 한 후 LogCat에서 코드 3 오류 만 발생했습니다. 누군가는 코드 3이 연결 오류라고 말하지만 같은 코드가 Android 4.4 아래에서 잘 작동하기 때문에 내 조건이되어서는 안됩니다.
아무도 도와 줄 수 있습니까?
감사합니다.
코드를 들여 쓰기/포맷/정리할 수 있습니까? LogCat에 표시된 모든 오류? – Raptor
코드 3은 CONNECTION_ERR입니다. 다른 Android 버전에서도 작동하는지는 중요하지 않습니다. IOException이 잡히면 서버가 200을 반환하지 않으므로 CONNECTION_ERR이 호출됩니다. 파일 전송 플러그인의 버그 일 수 있으며 코드바 JIRA의 문제를 채울 수 있습니다. – jcesarmobile
@jcesarmobile 네이티브 플러그인에서 루트를 찾으려면 어떤 제안이 필요합니까? 이미 기본 Android 프로젝트를 만들었으며 버그를 수정할 수 있다고 생각합니다. –