Skip to content

Commit 3743248

Browse files
authored
Fix exception type thrown for non-existing absolute paths. (#83)
1 parent 9aa5614 commit 3743248

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/src/main/java/com/cloudinary/android/payload/FilePayload.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,11 @@ public Object prepare(Context context) throws PayloadNotFoundException {
3030
}
3131

3232
private File getFile(Context context) throws FileNotFoundException {
33-
File file = new File(data);
33+
// check if data is an absolute path or a local app path and check if file exists:
34+
File file = data.contains(File.separator) ? new File(data) : context.getFileStreamPath(data);
3435

3536
if (!file.exists()) {
36-
37-
// check if it's a local app file:
38-
file = context.getFileStreamPath(data);
39-
if (!file.exists()) {
40-
throw new FileNotFoundException(String.format("File '%s' does not exist", data));
41-
}
37+
throw new FileNotFoundException(String.format("File '%s' does not exist", data));
4238
}
4339

4440
return file;

0 commit comments

Comments
 (0)