Skip to content

Commit

Permalink
ignore data images in image repository
Browse files Browse the repository at this point in the history
  • Loading branch information
repolevedavaj committed Apr 27, 2021
1 parent 35b914a commit 79498f0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/repositories/ImageRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import * as FileSystem from 'expo-file-system';
import ObjectUtils from "../common/ObjectUtils";

const PLANT_AVATARS_DIRECTORY = `${FileSystem.documentDirectory}/plant-avatars`;
const DATA_URI = 'data:';

class ImageRepository {

async storeImage(id: number, uri: string) {
if (uri.startsWith(PLANT_AVATARS_DIRECTORY)) {
if (uri.startsWith(PLANT_AVATARS_DIRECTORY) || uri.startsWith(DATA_URI)) {
return uri;
}

Expand All @@ -17,10 +18,7 @@ class ImageRepository {
const filename = this.createFilename(id, uri);
const destinationUri = `${PLANT_AVATARS_DIRECTORY}/${filename}`;

await FileSystem.copyAsync({
from: uri,
to: destinationUri
});
await FileSystem.copyAsync({from: uri, to: destinationUri});

return destinationUri;
}
Expand Down

0 comments on commit 79498f0

Please sign in to comment.