Welcome to the Rebex forum, Robert. Thanks for the question.
If i understand correctly:
1) You need to stream uploaded file over other network protocol.
2) Avoid storing file to the local file system.
2) Avoid storing full file content in the memory.
To fulfill requirements, you should use "immediate write stream".
E.g. assume that you need to stream an uploaded file to the Azure.
protected override NodeContent GetContent(NodeBase node, NodeContentParameters contentParams)
if (contentParams.AccessType == NodeContentAccess.Read)
//You have write only file system, throw;
var cloudBlobStream = getContainerReference(node.Parent.Path.FileName)
//CloudBlobStream immediately uploads data when its Write method is called.
return NodeContent.CreateImmediateWriteContent(cloudBlobStream); /
I don't know how exactly this code works.
The solution might be quite simple. Provide your own stream and upload the data.
class MySpecialStream : Stream
public override void Write(byte buffer, int offset, int count) => _myDataSink.Write(buffer, offset, count);
In this scenario you can safely ignore SaveContent method (see below).
Now, I will try to answer your questions.
1) GetContent method has NodeContentParameters argument that contains AccessType required by the file server operation (Read/Write or both).
To put it another way:
Imagine that if you call a hypothetical (Virtual)File.Open(....requiredAccess..) method, then GetContent method (...requiredAccess...) is the method that provides the result with required access.
SaveContent Method is kind of fall-back method. As documented, SaveContent method is called only when you return stream using the CreateDelayedWriteContent call in the GetContent method. Word 'Delayed' in the name of the method roughly means "I don't have stream that can save content immediately (e. g. FileStream), I am using some other stream and I promise (as an author of the virtual file system) that I will save content of this stream later when the SaveContent method is called."
2) a) GetContent method returns delayed write stream (in your case MemoryStream).
b) Provided stream is wrapped in a decorator to ensure that method SaveContent is called before the dispose of the stream is allowed.
c) File server closes (disposes) stream and method SaveContent is called with our decorator.
3) It follows from point 2 that method Dispose is called by the file server. You don't have to call Dispose method. If you don't like this behavior, you can wrap your stream in an own decorator that will have empty Dispose method.
4) No. I hope that from explanation above is clear that you are caching file in memory. You are using:
a) DelayedWriteContent method.
As I wrote above, please use CreateImmediateWriteContent method and suitable stream.
I am sorry for the confusion. We are aware that this part of our virtual file system is probably most complicated and unintuitive part. The reason is that we must support many different scenarios in many contexts. Write-only and pass-through virtual file system is one niche scenario. We tried to find common denominator, but I would like to point out that your feedback is very valuable for us.
I hope that this helps. Don't hesitate contact us again.