What I try to accomplish is to read from a stream directly into a field/record in SQL Server.
It isn’t hard to save a file to SQL Server, there are plenty of examples on the interweb;
but I can’t find any example that doesn’t read the whole file into memory first.
e.g.:
byte[] data = BinaryReader.ReadBytes((int)filestream.Length);
cmd.Parameters.Add("@Data", SqlDbType.Image, data.Length).Value = data;
or something similar.
I could use SQL Server’s own commands but then I’d have to fiddle with rights for SQL Server to read from another machine/folder and I’d hope to keep it all in .NET business layer instead.
The only way your going to be able to do that is to loop reading chunks from your stream & issuing an update on the underlying table using
UPDATE .WRITEor aFILESTREAM.This should not require any more permissions than a regular update/insert.