Skip to content

Commit

Permalink
feat: Added Picker-Storage linkage.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Dec 20, 2022
1 parent 9566153 commit 9ef85c6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/masamune/lib/masamune.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export 'package:katana_form/katana_form.dart';
export 'package:katana_indicator/katana_indicator.dart';
export 'package:katana_listenables/katana_listenables.dart';
export 'package:katana_localization/katana_localization.dart';
export 'package:katana_picker/katana_picker.dart';
export 'package:katana_model/katana_model.dart';
export 'package:katana_picker/katana_picker.dart';
export 'package:katana_router/katana_router.dart';
export 'package:katana_scoped/katana_scoped.dart';
export 'package:katana_shorten/katana_shorten.dart';
Expand All @@ -30,5 +30,6 @@ export 'package:meta/meta.dart' show useResult;

part 'form/form_scoped_widget.dart';
part 'model/model.dart';
part 'storage/storage.dart';
part 'scoped/controller.dart';
part 'src/masamune_app.dart';
18 changes: 18 additions & 0 deletions packages/masamune/lib/storage/storage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
part of masamune;

extension MasamunePickerUploaderAppRefExtensions on PickerValue {
Future<String> upload({String dirPath = ""}) async {
if (path.isEmpty) {
throw Exception("[path] was not found.");
}
final remoteFile = path!.trimQuery().trimStringRight("/").last();
final extension = remoteFile.last(separator: ".");
final storage = Storage(
StorageQuery(
"$dirPath/$uuid.$extension".trimQuery().trimStringLeft("/"),
),
);
await storage.upload(path!);
return await storage.publicURI;
}
}

0 comments on commit 9ef85c6

Please sign in to comment.