-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from takenet/feature/531586-improve-video-sto…
…rage feat: adding fileName field on controller and bubble
- Loading branch information
Showing
11 changed files
with
138 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:get/get.dart'; | ||
import 'package:path_provider/path_provider.dart'; | ||
|
||
abstract class DSDirectoryFormatter { | ||
static Future<String> getPath({ | ||
required final String type, | ||
required final String fileName, | ||
}) async { | ||
final cachePath = (await getApplicationCacheDirectory()).path; | ||
|
||
final typeFolder = '${type.split('/').first.capitalizeFirst}'; | ||
final extension = type.split('/').last; | ||
|
||
final typePrefix = '${typeFolder.substring(0, 3).toUpperCase()}-'; | ||
|
||
final newFileName = | ||
'${!fileName.startsWith(typePrefix) ? typePrefix : ''}$fileName'; | ||
|
||
final path = await _formatDirectory( | ||
type: typeFolder, | ||
directory: cachePath, | ||
); | ||
|
||
return '$path/$newFileName.$extension'; | ||
} | ||
|
||
static Future<String> _formatDirectory({ | ||
required final String type, | ||
required final String directory, | ||
}) async { | ||
final formattedDirectory = '$directory/$type'; | ||
final directoryExists = await Directory(formattedDirectory).exists(); | ||
|
||
if (!directoryExists) { | ||
await Directory(formattedDirectory).create(recursive: true); | ||
} | ||
|
||
return formattedDirectory; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.