From 6aafd8e5bc596f22b1030cd9bbf1c47be26bc764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Adasiewicz?= Date: Thu, 26 Jan 2023 12:26:12 +0100 Subject: [PATCH 1/2] fix(ui): temp file path on Windows --- packages/stream_chat_flutter/CHANGELOG.md | 1 + .../src/attachment/handler/stream_attachment_handler_io.dart | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index dfb83a73..f58a02be 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -3,6 +3,7 @@ 🐞 Fixed - [[#1424]](https://github.com/GetStream/stream-chat-flutter/issues/1424) Fixed a render issue when showing messages starting with 4 whitespaces. - Fixed a bug where the `AttachmentPickerBottomSheet` was not able to identify the mobile browser. +- Fixed uploading files on Windows - fixed temp file path. ## 5.2.0 diff --git a/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart b/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart index 45d5aab4..08f242de 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart @@ -123,7 +123,10 @@ class StreamAttachmentHandler extends StreamAttachmentHandlerBase { final tempDir = await getTemporaryDirectory(); final tempPath = Uri.file(tempDir.path, windows: CurrentPlatform.isWindows); - final tempFilePath = tempPath.resolve(fileName!).path; + var tempFilePath = tempPath.resolve(fileName!).path; + if (CurrentPlatform.isWindows && tempFilePath.startsWith('/')) { + tempFilePath = tempFilePath.substring(1); + } print(tempFilePath); final attachmentFileBytes = attachmentFile.bytes; From e0615a5b4fdc397ce82da7cbd6e05f49f59f19a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Adasiewicz?= Date: Thu, 26 Jan 2023 15:21:50 +0100 Subject: [PATCH 2/2] use .toFilePath instead --- .../attachment/handler/stream_attachment_handler_io.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart b/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart index 08f242de..268dbf15 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/handler/stream_attachment_handler_io.dart @@ -123,10 +123,9 @@ class StreamAttachmentHandler extends StreamAttachmentHandlerBase { final tempDir = await getTemporaryDirectory(); final tempPath = Uri.file(tempDir.path, windows: CurrentPlatform.isWindows); - var tempFilePath = tempPath.resolve(fileName!).path; - if (CurrentPlatform.isWindows && tempFilePath.startsWith('/')) { - tempFilePath = tempFilePath.substring(1); - } + final tempFilePath = tempPath + .resolve(fileName!) + .toFilePath(windows: CurrentPlatform.isWindows); print(tempFilePath); final attachmentFileBytes = attachmentFile.bytes;