fixes an issue where local files couldn't be picked | refactors temp cloud file name

This commit is contained in:
Miguel Ruivo 2018-08-16 15:43:42 +01:00
parent d9051223b3
commit 6ec2041e53
2 changed files with 11 additions and 21 deletions

View File

@ -25,7 +25,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -48,12 +48,12 @@ public class FilePickerPlugin implements MethodCallHandler {
Uri uri = data.getData();
Log.i(TAG, "URI:" +data.getData().toString());
String fullPath = Commons.getPath(uri, instance.context());
String cloudFile = null;
if(fullPath == null)
{
FileOutputStream fos = null;
cloudFile = instance.activeContext().getCacheDir()+data.getData().toString().split("/")[data.getData().toString().split("/").length-1];
cloudFile = instance.activeContext().getCacheDir().getAbsolutePath() + "/Document";
try {
fos = new FileOutputStream(cloudFile);
@ -76,22 +76,12 @@ public class FilePickerPlugin implements MethodCallHandler {
} catch (Exception e) {
e.printStackTrace();
}
}
Log.i(TAG, "FilePath:" + cloudFile);
Log.i(TAG, "Loaded file from cloud created on:" + cloudFile);
fullPath = cloudFile;
File file = new File(cloudFile);
if (Integer.parseInt(String.valueOf(file.length() / 1024)) > 1024) {
InputStream imageStream = null;
try {
imageStream = instance.activeContext().getContentResolver().openInputStream(uri);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Log.i(TAG, "FilePath:" + cloudFile);
}
Log.i(TAG, "FilePath:" + fullPath);
Log.i(TAG, "Absolute file path:" + fullPath);
result.success(fullPath);
}