Example of WebService file transfer

B

BobAchgill

Can you point me to a simple example of how to transfer
files using a web service.

Bob
 
J

Jason

You can Google for ".net, DIME, web service" and you should be able to
find samples. But basically, in your web method, to attach a file, it's
just:

DimeAttachment objAttachment;
objAttachment = new
DimeAttachment("application/unknown", TypeFormat.MediaType,
"blah.blah");
ResponseSoapContext.Current.Attachments.Add(objAttachment);


To get a file, it's

AttachmentCollection objAttachments =
RequestSoapContext.Current.Attachments;
if(objAttachments != null) {
foreach(DimeAttachment objAttachment in objAttachments) {
byte[] data = new byte[objAttachment.Stream.Length];
objAttachment.Stream.Read(data, 0, (int)
objAttachment.Stream.Length);
System.IO.FileStream objFile = System.IO.File.Create("whatitis.foo");
objFile.Write(data, 0, data.Length);
objFile.Close();
}
}

Hope this helps...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top