use of info.guardianproject.iocipher.FileOutputStream in project Zom-Android by zom.
the class SecureMediaStore method copyToVfs.
public static void copyToVfs(InputStream sourceIS, String targetPath) throws IOException {
// create the target directories tree
mkdirs(targetPath);
// copy
FileOutputStream fos = new FileOutputStream(new File(targetPath), false);
IOUtils.copyLarge(sourceIS, fos);
fos.close();
sourceIS.close();
}
use of info.guardianproject.iocipher.FileOutputStream in project Zom-Android by zom.
the class SecureMediaStore method resizeAndImportImage.
/**
* Resize an image to an efficient size for sending via OTRDATA, then copy
* that resized version into vfs. All imported content is stored under
* /SESSION_NAME/ The original full path is retained to facilitate browsing
* The session content can be deleted when the session is over
*
* @param sessionId
* @return vfs uri
* @throws IOException
*/
public static Uri resizeAndImportImage(Context context, String sessionId, Uri uri, String mimeType) throws IOException {
String originalImagePath = uri.getPath();
String targetPath = "/" + sessionId + "/upload/" + UUID.randomUUID().toString() + "/image";
boolean savePNG = false;
if (originalImagePath.endsWith(".png") || (mimeType != null && mimeType.contains("png")) || originalImagePath.endsWith(".gif") || (mimeType != null && mimeType.contains("gif"))) {
savePNG = true;
targetPath += ".png";
} else {
targetPath += ".jpg";
}
// load lower-res bitmap
Bitmap bmp = getThumbnailFile(context, uri, DEFAULT_IMAGE_WIDTH);
File file = new File(targetPath);
file.getParentFile().mkdirs();
FileOutputStream out = new info.guardianproject.iocipher.FileOutputStream(file);
if (savePNG)
bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
else
bmp.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
bmp.recycle();
return vfsUri(targetPath);
}
use of info.guardianproject.iocipher.FileOutputStream in project Zom-Android by zom.
the class IOCipherOmemoStore method writeIntegers.
private void writeIntegers(File target, Set<Integer> integers) throws IOException {
if (target == null) {
throw new IOException("Could not write integers to null-path.");
}
IOException io = null;
DataOutputStream out = null;
try {
out = new DataOutputStream(new FileOutputStream(target));
for (int i : integers) {
out.writeInt(i);
}
} catch (IOException e) {
io = e;
} finally {
if (out != null) {
out.close();
}
}
if (io != null) {
throw io;
}
}
use of info.guardianproject.iocipher.FileOutputStream in project Zom-Android by zom.
the class IOCipherOmemoStore method writeBytes.
private void writeBytes(File target, byte[] bytes) throws IOException {
if (target == null) {
throw new IOException("Could not write bytes to null-path.");
}
// Create file
FileHierarchy.createFile(target);
IOException io = null;
DataOutputStream out = null;
try {
out = new DataOutputStream(new FileOutputStream(target));
out.write(bytes);
} catch (IOException e) {
io = e;
} finally {
if (out != null) {
out.close();
}
}
if (io != null) {
throw io;
}
}
Aggregations