I watched this topic: How to handle large file uploads through WCF?
I need to have a web service hosted by my provider, where I need to upload and download files. We are talking videos from 1Mb to 100Mb, hence the streaming approach.
I cannot make it work, I declared the interface:
[ServiceContract]
public interface IFileTransferService
{
[OperationContract]
void UploadFile(Stream stream);
}
and everything is fine, I implement it as follows:
public string FileName = "test";
public void UploadFile(Stream stream)
{
try
{
FileStream outStream = File.Open(FileName, FileMode.Create, FileAccess.Write);
const int bufferLength = 4096;
byte[] buffer = new byte[bufferLength];
int count = 0;
while((count = stream.Read(buffer, 0, bufferLength)) > 0)
{
outStream.Write(buffer, 0, count);
}
outStream.Close();
stream.Close();
}
catch(Exception ex)
{
throw new Exception("error: "+ex.Message);
}
}
Still not a problem, it was published on my web server in interweb. So far so good.
Now I will make a link to it and pass it the FileStream, but the argument is now a byte [] - why is this and how can I get it properly for streaming?
Edit
My bindings look like this:
<bindings>
<basicHttpBinding>
<binding name="StreamingFileTransferServicesBinding"
transferMode="StreamedRequest"
maxBufferSize="65536"
maxReceivedMessageSize="204003200" />
</basicHttpBinding>
</bindings>
- , []
2
! , . "-" " ". []/stream