From a83cbf965e044d7fedff6388580964c1a0de175d Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Tue, 9 Mar 2021 10:49:49 -0600 Subject: [PATCH] MultiplartSectionBody streams have 0 length until read. (#1196) --- src/Core/Services/Implementations/CipherService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Core/Services/Implementations/CipherService.cs b/src/Core/Services/Implementations/CipherService.cs index 2ea499913b..c781108f8e 100644 --- a/src/Core/Services/Implementations/CipherService.cs +++ b/src/Core/Services/Implementations/CipherService.cs @@ -222,10 +222,11 @@ namespace Bit.Core.Services AttachmentId = attachmentId, FileName = fileName, Key = key, - Size = stream.Length }; await _attachmentStorageService.UploadNewAttachmentAsync(stream, cipher, data); + // Must read stream length after it has been saved, otherwise it's 0 + data.Size = stream.Length; try {