@Test public void should_preserveExtension_whenSavingUri() throws Exception { final ImageDiskStore imageDiskStore = new ImageDiskStore(); final Application appContext = getApplicationContext(); final Uri uri = getUriAndRegisterInputStream(appContext); imageDiskStore.save(appContext, uri); final File storeDir = new File(appContext.getFilesDir(), ImageDiskStore.STORE_DIR); assertThat(storeDir.listFiles()[0].getName()).endsWith(".jpg"); }
@Nullable public Uri save(@NonNull final Context context, @NonNull final byte[] bytes) { final Uri uri = generateUri(context, null); final File file = createFile(uri); if (file == null) { return null; } try { writeToFile(file, bytes); return uri; } catch (final IOException e) { LOG.error("Failed to write file", e); return null; } }
ImageDiskStore { @Nullable public Uri save(@NonNull final Context context, @NonNull final byte[] bytes) { final Uri uri = generateUri(context, null); final File file = createFile(uri); if (file == null) { return null; } try { writeToFile(file, bytes); return uri; } catch (final IOException e) { LOG.error("Failed to write file", e); return null; } } }
ImageDiskStore { @Nullable public Uri save(@NonNull final Context context, @NonNull final byte[] bytes) { final Uri uri = generateUri(context, null); final File file = createFile(uri); if (file == null) { return null; } try { writeToFile(file, bytes); return uri; } catch (final IOException e) { LOG.error("Failed to write file", e); return null; } }  }
ImageDiskStore { @Nullable public Uri save(@NonNull final Context context, @NonNull final byte[] bytes) { final Uri uri = generateUri(context, null); final File file = createFile(uri); if (file == null) { return null; } try { writeToFile(file, bytes); return uri; } catch (final IOException e) { LOG.error("Failed to write file", e); return null; } }  @Nullable Uri save(@NonNull final Context context, @NonNull final byte[] bytes); @Nullable Uri save(@NonNull final Context context, @NonNull final Uri fromUri); boolean update(@NonNull final Uri uri, @NonNull final byte[] bytes); void delete(@NonNull final Uri uri); static void clear(@NonNull final Context context); }
ImageDiskStore { @Nullable public Uri save(@NonNull final Context context, @NonNull final byte[] bytes) { final Uri uri = generateUri(context, null); final File file = createFile(uri); if (file == null) { return null; } try { writeToFile(file, bytes); return uri; } catch (final IOException e) { LOG.error("Failed to write file", e); return null; } }  @Nullable Uri save(@NonNull final Context context, @NonNull final byte[] bytes); @Nullable Uri save(@NonNull final Context context, @NonNull final Uri fromUri); boolean update(@NonNull final Uri uri, @NonNull final byte[] bytes); void delete(@NonNull final Uri uri); static void clear(@NonNull final Context context);  }