기본 모듈 내에서 티타늄으로 저장된 파일에 액세스하려면 어떻게해야합니까? 제 코드에서는 카메라로 찍은 사진 (Ti.Media)을 파일로 저장합니다. 그런 다음 모듈에서 동일한 파일을 읽으려고합니다. nativePath
을 모듈의 메서드에 전달 중입니다. 하지만, 내 모듈에서 파일을 찾을 수 없습니다 오류가 계속. 카메라 성공 콜백에서 티타늄/Android는 기본 모듈의 티타늄에서 생성 된 파일에 액세스합니다.
// earlier in the code
var tiexif = require('com.me.tiexif');
Ti.Media.showCamera({
success: function(event) {
console.log("TIEXIF: showCamera.success()");
anImageView.image = event.media; // works
if (Ti.Filesystem.hasStoragePermissions()) {
console.log("TIEXIF: hasStoragePermissions");
var file = Titanium.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'testphoto.jpg');
console.log("TIEXIF: nativePath: " + file.nativePath);
file.write(event.media);
someUILabel.text = tiexif.getExifOrientation(file.nativePath);
} else ...
}, ...
})
을 나는 로그에서 볼 :
[INFO] TIEXIF: showCamera.success()
[ERROR] File: fail readDirectory() errno=20
[ERROR] File: fail readDirectory() errno=13
[ERROR] File: fail readDirectory() errno=13
[ERROR] File: fail readDirectory() errno=13
[INFO] TIEXIF: hasStoragePermissions
[INFO] TIEXIF: nativePath: file:///storage/emulated/0/com.me.exiftest/testphoto.jpg
[WARN] ExifInterface: Invalid image.
[WARN] ExifInterface: java.io.FileNotFoundException: file:/storage/emulated/0/com.me.exiftest/testphoto.jpg: open failed: ENOENT (No such file or directory)
내가 함께 시도 externalStorageDirectory
, applicationDataDirectory
, tempDirectory
및 applicationCacheDirectory
모두와 같은 결과. 내가 리소스 폴더에서 파일을 열 그것을 사용하고
private String getPathToApplicationAsset(String assetName) {
// The url for an application asset can be created by resolving the specified
// path with the proxy context. This locates a resource relative to the
// application resources folder
String result = resolveUrl(null, assetName);
return result;
}
// ...
String imageSrc = options.getString("image");
// ...
String url = getPathToApplicationAsset(imageSrc);
TiBaseFile file = TiFileFactory.createTitaniumFile(new String[] { url }, false);
:
ExifInterface를 사용하려고합니다. 생성자는 문서에서 파일 이름을 나타내는 String을 허용합니다. 나는 그것이 파일 경로를 의미한다고 가정하고 있었지만 아마도 앱의 데이터 디렉토리와 관련된 이름 일 것입니다. https://developer.android.com/reference/android/media/ExifInterface.html#ExifInterface(java.lang.String) – skypanther
아 좋아, 파일을 열고 exif에 액세스하는 fh.imagefactory에 대한 링크를 추가했습니다. 정보 (파일 부분을 지울 것입니다.) 그게 너에게 도움이 될거야. – miga
감사합니다. 신입 사원 레포에 대한 링크는 훌륭합니다. 모듈을 Ti 개발자가 쉽게 사용할 수 있도록 앱 사이드를 만드는 것보다 낫습니다. – skypanther