import Base64 from "android.util.Base64"; import MimeTypeMap from "android.webkit.MimeTypeMap"; import ByteArrayOutputStream from 'java.io.ByteArrayOutputStream'; import File from "java.io.File"; import FileInputStream from "java.io.FileInputStream"; import FileOutputStream from "java.io.FileOutputStream"; import InputStream from 'java.io.InputStream'; // import IOException from "java.io.IOException"; import {ProcessFileOptions, NullableString} from '../interface' type NullByteArray = ByteArray | null function inputStreamToArray(inputStream : InputStream) : NullByteArray { try { let bos : ByteArrayOutputStream = new ByteArrayOutputStream() let bytes : ByteArray = new ByteArray(1024) do { let length = inputStream.read(bytes) if (length != -1) { bos.write(bytes, 0, length) } else { break } } while (true) bos.close() return bos.toByteArray() } catch (e : Throwable) { return null; } } function getMimeType(filePath : string):NullableString { const extension = MimeTypeMap.getFileExtensionFromUrl(filePath); if(extension == null) return null return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); } export function getResourcePath(path: string): string|null { let uri = path if (uri.startsWith("http") || uri.startsWith("