diff --git a/lib/core/app_data_manager.dart b/lib/core/app_data_manager.dart index 93a1ea5..a29bf29 100644 --- a/lib/core/app_data_manager.dart +++ b/lib/core/app_data_manager.dart @@ -44,20 +44,19 @@ class AppDataManager { var c = Completer(); var number = 0; var shell = StringBuffer(); - switch (this._scm) { + switch (_scm) { case SCMType.Svn: break; case SCMType.Git: shell.writeln('git rev-list --all HEAD --all --count'); - var process = - await ProcessExecutor.start(shell, workspace: this._workspace); + var process = await ProcessExecutor.start(shell, workspace: _workspace); await process.process.exitCode; number = int.parse(process.stdoutArr.last); break; } - var version = this.numberToVersion(number); - print('#### Version: ' + version); + var version = numberToVersion(number); + print('#### Version: $version'); c.complete(version); return c.future; } @@ -97,7 +96,7 @@ class AppDataManager { await ProcessExecutor.start(shell, workspace: this._workspace); await process.process.exitCode; var hash = process.stdoutArr.last; - print('#### Git Hash: ' + hash); + print('#### Git Hash: $hash'); c.complete(hash); return c.future; } @@ -105,7 +104,7 @@ class AppDataManager { String getBuildTime() { var date = DateTime.now().toString(); date = date.substring(0, date.lastIndexOf('.')); - print('#### Build Date: ' + date); + print('#### Build Date: $date'); return date; } diff --git a/lib/core/log.dart b/lib/core/log.dart index 8a64b4d..bedab3d 100644 --- a/lib/core/log.dart +++ b/lib/core/log.dart @@ -116,6 +116,7 @@ class Log { if (message.type == 'request') { write(); } else if (message.type == 'ready') { + path = message.message as String; appendString('Log path: ${message.message}'); } } diff --git a/lib/utils/slack/slack_data.dart b/lib/utils/slack/slack_data.dart index c4f2521..db1c1de 100644 --- a/lib/utils/slack/slack_data.dart +++ b/lib/utils/slack/slack_data.dart @@ -182,14 +182,13 @@ class SlackConfirm { } // To-do: File upload test -@JsonSerializable() class SlackFile { String? title; // ignore: non_constant_identifier_names String? initial_comment; - String? filePath; String? fileName; String? mimeType; + late File file; Future setFileData(MultipartRequest form) async { // var bytes = await readFileByte(filePath!); @@ -202,8 +201,7 @@ class SlackFile { form.fields['filetype'] = "auto"; //참조 - https://api.slack.com/types/file#file_types if (fileName != null && mimeType != null) { - form.files.add(MultipartFile.fromBytes( - 'file', await File.fromUri(Uri.parse(filePath!)).readAsBytes(), + form.files.add(await MultipartFile.fromPath('file', file.path, contentType: MediaType(HttpHeaders.contentTypeHeader, mimeType!))); } var c = Completer(); diff --git a/lib/utils/slack/slack_data.g.dart b/lib/utils/slack/slack_data.g.dart index 5a02a94..e003b61 100644 --- a/lib/utils/slack/slack_data.g.dart +++ b/lib/utils/slack/slack_data.g.dart @@ -182,18 +182,3 @@ Map _$SlackConfirmToJson(SlackConfirm instance) => 'ok_text': instance.ok_text, 'dismiss_text': instance.dismiss_text, }; - -SlackFile _$SlackFileFromJson(Map json) => SlackFile() - ..title = json['title'] as String? - ..initial_comment = json['initial_comment'] as String? - ..filePath = json['filePath'] as String? - ..fileName = json['fileName'] as String? - ..mimeType = json['mimeType'] as String?; - -Map _$SlackFileToJson(SlackFile instance) => { - 'title': instance.title, - 'initial_comment': instance.initial_comment, - 'filePath': instance.filePath, - 'fileName': instance.fileName, - 'mimeType': instance.mimeType, - }; diff --git a/lib/utils/slack/slack_sender.dart b/lib/utils/slack/slack_sender.dart index ac6fd2e..b8c08cc 100644 --- a/lib/utils/slack/slack_sender.dart +++ b/lib/utils/slack/slack_sender.dart @@ -109,15 +109,22 @@ class SlackSender { return form; } - void sendFile(String channel, SlackFile file, + Future sendFile(String channel, SlackFile file, {String? targetUser, Function(String)? completeListener, Function(Exception)? errorListener}) async { + var c = Completer(); _completeListener = completeListener; _errorListener = errorListener; var form = getPostForm(urlFileUplaod, channel, targetUser); form = await file.setFileData(form); - //To-do: send http + var response = await form.send(); + + var result = await response.stream.bytesToString(); + if (_completeListener != null) _completeListener!(result); + + c.complete(); + return c.future; } /// ****************** Send template ******************* @@ -143,7 +150,7 @@ class SlackSender { SlackField.withParam('Test4', 'Value4'), ]; message.attachments.add(attachment); - sends('app_notifier', message, targetUser: 'toki'); + await sends('app_notifier', message, targetUser: 'toki'); } Future sendBuild(String appName, SlackBuildType buildType, Color color,