Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upload files using WCF

Tags:

c#

wcf

I need a WCF Service to upload large files by user.

Which one of the below gives a more optimized performance

  [OperationContract]
  public void UploadFile(Stream inputsreaam);

or

   [OperationContract]
   public void UploadFile(byte[] buffer);

any other suggestions are welcome

like image 706
Gerry Avatar asked Aug 16 '26 07:08

Gerry


1 Answers

If you want to upload really large files, use the Stream one. If you transfer a 2 Gb file as byte[] this will be loaded to memory on the server and only than you can save it somewhere. With the Stream you can read from client stream and write to file or DB stream on the server with only small chunks of data actually in memory. Back to performance: with really large files and multiple clients byte[] is likely to freeze your server for lack of memory.

You may also find this tutorial helpful.

like image 61
Maxim Zabolotskikh Avatar answered Aug 17 '26 22:08

Maxim Zabolotskikh