Hi Rupesh,
Thanks for your response.
The link which you have shared is getting URL of the attachment. But I want to download all the attachments using ECMAScript.
I am able to download the list Item attachments using .net Managed code Client object model but I need it in ECMAScript.
Here is code to download attachment in Managed code. Let me know how to download it in ECMAScript.
void DownLoadattListAchment()
{
string SiteURL = @"SharePointSiteURL";
try
{
ClientContext context = new ClientContext(SiteURL);
{
Web web = context.Web;
List list = web.Lists.GetByTitle("Test");
context.Load(list);
context.ExecuteQuery();
Folder folder = web.GetFolderByServerRelativeUrl("Lists/test/Attachments/"+1);
context.Load(folder);
context.ExecuteQuery();
FileCollection attachments = folder.Files;
context.Load(attachments);
context.ExecuteQuery();
NetworkCredential credentials = new NetworkCredential("UserName", "Password", "domain");
WebClient client1 = new WebClient();
client1.Credentials = credentials;
string downloadLocation = @"D:\MultipleDoc\";
foreach (Microsoft.SharePoint.Client.File oFile in folder.Files)
{
byte[] fileContents = client1.DownloadData("http://domain:8888" +oFile.ServerRelativeUrl);
//FileStream fStream = new FileStream(downloadLocation + oFile.Name, FileMode.Create);
FileStream fStream = new FileStream(downloadLocation + oFile.Name, FileMode.Create);
fStream.Write(fileContents, 0, fileContents.Length);
fStream.Close();
}
}
}
catch (Exception ex)
{
}
}