function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mandarmandar 

Downloading attachments via API

I'm trying to download via the API, about 250 MB worth of attachments that our support team has attached to cases to free up some space. The files have different formats like jpeg, doc, xls, etc. I looked at the API. The Body and Name fields in the Attachment object seems to have what I need to create the object locally. However, I don't know what the next step should be to convert it from byte[] to the final object on disk locally. I'm using C#, Visual Studio 2005, .Net Framework 2.0. Can some one point me to some sample code/documentation in this regard?

Thanks in advance!

SuperfellSuperfell
create a FileStream, write the bytes to it, close the stream.

using (FileStream fs = new FileStream(@"c:\someFile.jpg", FileMode.Create)) {
fs.Write(buff, 0, buff.Length);
}

where buff is your byte[] from the query or retrieve call.