How to save very large file to output stream (write only stream) (C# .NET)

We have very large file and want to save it right to DataBase (to MongoDB), without MemoryStream (we have memory limit and a lot of work with large files simultaneously ). Other words, Does Aspose.Slides(and .Words, .Cells) support stream saving?

Below, this is exception, when Aspose want to read (why? we have not idea…) from upload stream.

Unhandled task exception: "System.NotSupportedException: Specified method is not supported.
at MongoDB.Driver.GridFS.GridFSForwardOnlyUploadStream1.Read(Byte[] buffer, Int32 offset, Int32 count) at Smartcat.MongoDBPersistence.GridFS.ManagedGridFSUploadStream1.Read(Byte[] buffer, Int32 offset, Int32 count) in C:_Projects\MongoDBPersistence\MongoDBPersistence.GridFS\ManagedGridFSUploadStream.cs:line 88
at Smartcat.MongoDBPersistence.GridFS.Repository.GridFSStreamWithId`1.Read(Byte[] buffer, Int32 offset, Int32 count) in C:_Projects\MongoDBPersistence\MongoDBPersistence.GridFS\Repository\GridFSStreamWithId.cs:line 346
at Aspose.Slides. .(Stream , , UInt64 )
at Aspose.Slides. .(Stream , UInt64 )
at Aspose.Slides. .(Stream )
at Aspose.Slides. .(Stream )
at Aspose.Slides. .(Stream )
at Aspose.Slides. .(Stream )
at Aspose.Slides. .(Guid , Stream )

at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format)

Thank you!
p.s. version of Aspose.* is 19.11.0


I have observed the issue shared by you and like to share that Aspose.Slides does support load and saving presentation to Streams. However, you need to make sure that you have set stream position to 0 before loading and after saving the presentation object. I suggest you to please also try using Aspose.Slides for .NET 20.2 on your end as well. If the issue still persist please share the working sample project reproducing the issue.

We known, that method Save can work with Stream (we pass stream to it), but now it is required, that all big file must be in memory (via MemoryStream in C#)! Because stream for Uploading does not support Read operations and Aspose wants to Read from this Stream some data (why??). It looks like Aspose does not support stream saving. Can you ask developers about it? Please.
Upgrade to 20.2 is not good decision.


Thank you for sharing your feedback. I have created an issue with ID SLIDESNET-41793 in our issue tracking system to further investigate the issue. We will share the notification with you as soon as the feedback will be shared.


The BlobManagementOptions should help to manage large size streams. This functionality is intended to handle large presentations (presentations with large media data) not loading it to memory, including saving. You can find additional information in release notes and in API reference guide.

LoadOptions loadOptions = new LoadOptions();
loadOptions.BlobManagementOptions.PresentationLockingBehavior = PresentationLockingBehavior.KeepLocked;
loadOptions.BlobManagementOptions.MaxBlobsBytesInMemory = 200 * 1024 & 1024; //set buffer size to 200 MB
loadOptions.BlobManagementOptions.IsTemporaryFilesAllowed = true;

using (Presentation pres = new Presentation("source.pptx", loadOptions))
    using (Stream stream = new FileStream("target.pptx", FileMode.OpenOrCreate)) //use any stream you want here
        pres.Save(stream, SaveFormat.Pptx);

Thank you very much!


It’s good to know things are resolved on your end.

The issues you have found earlier (filed as SLIDESNET-41793) have been fixed in this update.