I am building a digital signage application and i need to allow my users to upload large images/videos. I have looked at the streaming mode to allow upload and download of the file, which seems to be the way to go. My problem is though that i need to figure out the proper approach to uploading. I need to put an entry into my database, then upload the file to a specific folder on the server (each customer has his own folder, whre the file needs to be placed). My problem is that it doesnt seem possible to send more information along with the file, than the stream to upload. All i need is some metadata, name of file and customer id. Anyone has a working example of this or point me in the right direction...
Sincerely 开发者_如何学Go/Brian
Well, you're not saying what you've tried and how it failed, but here's a basic outline of how we're doing it:
[ServiceContract]
public interface IMyStreamingService
{
[OperationContract]
void Upload(FileUploadRequest request);
}
[MessageContract]
public class FileUploadRequest
{
[MessageHeader(MustUnderstand = true)]
public string Path;
[MessageBodyMember(Order = 1)]
public Stream FileData;
public FileUploadRequest(string path, Stream fileData)
{
this.Path = path;
this.FileData = fileData;
}
}
I have answered similar question few days ago. You have to declare operation which accepts and returns message contracts. You have to create message contracts. For streaming contract can contain only single body member which is of type Stream. Other contract members must to be declared as headers. Linked question contains full example for downloading. You just need to do the same for uploading.
精彩评论