|
|
@ -105,16 +105,27 @@ public class CameraUtils { |
|
|
|
@WorkerThread |
|
|
|
@WorkerThread |
|
|
|
@SuppressLint("NewApi") |
|
|
|
@SuppressLint("NewApi") |
|
|
|
public static Uri writeToFile(Context context, @NonNull final byte[] data, @NonNull Uri file) { |
|
|
|
public static Uri writeToFile(Context context, @NonNull final byte[] data, @NonNull Uri file) { |
|
|
|
|
|
|
|
OutputStream stream = null; |
|
|
|
|
|
|
|
Uri result; |
|
|
|
try { |
|
|
|
try { |
|
|
|
ParcelFileDescriptor fd = context.getContentResolver().openFileDescriptor(file, "w"); |
|
|
|
ParcelFileDescriptor fd = context.getContentResolver().openFileDescriptor(file, "w"); |
|
|
|
OutputStream stream = new ParcelFileDescriptor.AutoCloseOutputStream(fd); |
|
|
|
stream = new ParcelFileDescriptor.AutoCloseOutputStream(fd); |
|
|
|
stream.write(data); |
|
|
|
stream.write(data); |
|
|
|
stream.flush(); |
|
|
|
stream.flush(); |
|
|
|
|
|
|
|
result = file; |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
return null; |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
return file; |
|
|
|
try { |
|
|
|
|
|
|
|
if (stream != null) { |
|
|
|
|
|
|
|
stream.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception ignored) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|