Store remote data in ApplicationSupportDirectory
This commit is contained in:
parent
15878630b5
commit
bce30d7729
2 changed files with 3 additions and 15 deletions
|
@ -27,7 +27,7 @@ class RemoteAssetsService {
|
|||
}
|
||||
|
||||
Future<String> _getLocalPath(String remotePath) async {
|
||||
return (await getTemporaryDirectory()).path +
|
||||
return (await getApplicationSupportDirectory()).path +
|
||||
"/assets/" +
|
||||
_urlToFileName(remotePath);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ import "dart:async";
|
|||
import "dart:io";
|
||||
|
||||
import "package:connectivity_plus/connectivity_plus.dart";
|
||||
import "package:flutter/services.dart";
|
||||
import "package:logging/logging.dart";
|
||||
import "package:path/path.dart";
|
||||
import "package:path_provider/path_provider.dart";
|
||||
|
@ -134,13 +133,13 @@ abstract class MLFramework {
|
|||
}
|
||||
|
||||
Future<String> _getLocalImageModelPath() async {
|
||||
return (await getTemporaryDirectory()).path +
|
||||
return (await getApplicationSupportDirectory()).path +
|
||||
"/models/" +
|
||||
basename(getImageModelRemotePath());
|
||||
}
|
||||
|
||||
Future<String> _getLocalTextModelPath() async {
|
||||
return (await getTemporaryDirectory()).path +
|
||||
return (await getApplicationSupportDirectory()).path +
|
||||
"/models/" +
|
||||
basename(getTextModelRemotePath());
|
||||
}
|
||||
|
@ -176,17 +175,6 @@ abstract class MLFramework {
|
|||
return connectivityResult != ConnectivityResult.mobile ||
|
||||
shouldDownloadOverMobileData;
|
||||
}
|
||||
|
||||
Future<String> getAccessiblePathForAsset(
|
||||
String assetPath,
|
||||
String tempName,
|
||||
) async {
|
||||
final byteData = await rootBundle.load(assetPath);
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
final file = await File('${tempDir.path}/$tempName')
|
||||
.writeAsBytes(byteData.buffer.asUint8List());
|
||||
return file.path;
|
||||
}
|
||||
}
|
||||
|
||||
class MLFrameworkInitializationUpdateEvent extends Event {
|
||||
|
|
Loading…
Reference in a new issue