Description
Describe the bug
creatingStream was disposed , which made the event hander could not manipulate the stream.
Orchard Core version
latest main
To Reproduce
- Go to CreateFileFromStreamAsync of DefaultMediaFileStore
- See error
The stream was not opened for writing.
or disposed
Expected behavior
Logs and screenshots
2025-04-27 16:06:36.0753|Default|00-2f2c2e1e33d2f3a42eac04632ee95bfd-38307f23cf03942c-00||OrchardCore.Media.Controllers.AdminController|ERROR|An error occurred while uploading a media OrchardCore.FileStorage.FileStoreException: Cannot create file 'zg2/Andy-UX.docx'.
---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.String'.
at Microsoft.AspNetCore.Http.ReferenceReadStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
at System.IO.Stream.<CopyToAsync>g__Core|27_0(Stream source, Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
at OrchardCore.FileStorage.FileSystem.FileSystemStore.CreateFileFromStreamAsync(String path, Stream inputStream, Boolean overwrite)
--- End of inner exception stack trace ---
at OrchardCore.FileStorage.FileSystem.FileSystemStore.CreateFileFromStreamAsync(String path, Stream inputStream, Boolean overwrite)
at OrchardCore.Media.Core.DefaultMediaFileStore.CreateFileFromStreamAsync(String path, Stream inputStream, Boolean overwrite)
at OrchardCore.Media.Controllers.AdminController.<>c__DisplayClass19_0.<<Upload>b__1>d.MoveNext() at OrchardCore.FileStorage.FileSystem.FileSystemStore.CreateFileFromStreamAsync(String path, Stream inputStream, Boolean overwrite)
at OrchardCore.Media.Core.DefaultMediaFileStore.CreateFileFromStreamAsync(String path, Stream inputStream, Boolean overwrite)
at OrchardCore.Media.Controllers.AdminController.<>c__DisplayClass19_0.<<Upload>b__1>d.MoveNext()