Skip to content

Commit

Permalink
Renamed Action & Added type property
Browse files Browse the repository at this point in the history
  • Loading branch information
mehsaandev committed Dec 31, 2024
1 parent 7d457fa commit 0535da8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ class SaveToFileSystemAction extends EnsembleAction {
final String? fileName;
final dynamic blobData;
final String? source; // Optional source for URL if blobData is not available
final String? type; // file type

SaveToFileSystemAction({
required this.fileName,
this.blobData,
this.source,
this.type,
});

factory SaveToFileSystemAction.from({Map? payload}) {
Expand All @@ -31,6 +33,7 @@ class SaveToFileSystemAction extends EnsembleAction {
fileName: payload['fileName'],
blobData: payload['blobData'],
source: payload['source'],
type: payload['type'],
);
}

Expand Down Expand Up @@ -66,10 +69,11 @@ class SaveToFileSystemAction extends EnsembleAction {

// Determine file type based on file extension
final fileExtension = fileName!.split('.').last.toLowerCase();
if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].contains(fileExtension)) {
// if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].contains(fileExtension)) {
if (type == 'image') {
// Save images to DCIM/Pictures
await _saveImageToDCIM(fileName!, fileBytes!);
} else {
} else if (type == 'document') {
// Save documents to Documents folder
await _saveDocumentToDocumentsFolder(fileName!, fileBytes!);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/ensemble/lib/framework/action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'package:ensemble/action/change_locale_actions.dart';
import 'package:ensemble/action/misc_action.dart';
import 'package:ensemble/action/navigation_action.dart';
import 'package:ensemble/action/notification_actions.dart';
import 'package:ensemble/action/save_to_gallery.dart';
import 'package:ensemble/action/save_file.dart';
import 'package:ensemble/action/phone_contact_action.dart';
import 'package:ensemble/action/sign_in_out_action.dart';
import 'package:ensemble/action/toast_actions.dart';
Expand Down

0 comments on commit 0535da8

Please sign in to comment.