WCF Chunking / Streaming

后端 未结 4 1890
再見小時候
再見小時候 2021-01-31 12:03

I\'m using WCF and want to upload a large file from the client to the server. I have investigated and decided to follow the chunking approach outlined at http://msdn.microsoft.c

4条回答
  •  清酒与你
    2021-01-31 12:40

    You could make your service session-ful and have an initialization method in the contract with the IsInitiating property set to true. Something like:

    [OperationContract(IsInitiating = true)]
    void InitializeUploadService(string filename);
    
    [OperationContract(IsOneWay = true, IsInitiating = false)]
    [ChunkingBehavior(ChunkingAppliesTo.InMessage)]
    void UploadStream(Stream stream);
    

    I have never tried it with streaming services but it should basically make WCF enforce that InitializeUploadService is always called before UploadStream.

    More documentation can be found here: http://msdn.microsoft.com/en-us/library/system.servicemodel.description.operationdescription.isinitiating.aspx

提交回复
热议问题