mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-02-22 13:12:50 +08:00
fix(android): Fixed unsafe reading of temporary file
This commit is contained in:
parent
6cd2b1db61
commit
0da946d770
@ -783,9 +783,17 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
||||
try {
|
||||
String modifiedPath = this.outputModifiedBitmap(bitmap, uri, mimeTypeOfGalleryFile);
|
||||
InputStream fileStream = FileHelper.getInputStreamFromUriString(modifiedPath, cordova);
|
||||
byte[] file = new byte[fileStream.available()];
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
fileStream.read(file);
|
||||
int nRead;
|
||||
byte[] data = new byte[512];
|
||||
|
||||
while ((nRead = fileStream.read(data, 0, data.length)) != -1) {
|
||||
buffer.write(data, 0, nRead);
|
||||
}
|
||||
|
||||
buffer.flush();
|
||||
byte[] file = buffer.toByteArray();
|
||||
|
||||
byte[] output = Base64.encode(file, Base64.NO_WRAP);
|
||||
String js_out = new String(output);
|
||||
|
Loading…
Reference in New Issue
Block a user