Download Images with RenditionID


  • Hello,

    I am able to download Images from SPO using code given below. My question is how to maintain the original size of the image which is mentioned in URL. (RenditionID=5 in my case)

    public static void DownoadFile(string FilePath,string DestinationPath)
                //Filepath parameter to be passed below
                Uri filename = new Uri(@"");
                string server = filename.AbsoluteUri.Replace(filename.AbsolutePath, "");
                string serverrelative = filename.AbsolutePath;
                ClientContext clientContext = new ClientContext("");
                clientContext.Credentials = GetO365Credentials(ConfigurationManager.AppSettings["username"], ConfigurationManager.AppSettings["password"]);
                FileInformation f = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, serverrelative);
                //DestinationPath parameter to be used below
                using (var fileStream = new FileStream(@"c:\Test.jpg", FileMode.Create))
    		public static SharePointOnlineCredentials GetO365Credentials(string userName, string passWord)
                SecureString securePassWord = new SecureString();
                foreach (char c in passWord.ToCharArray()) securePassWord.AppendChar(c);
                SharePointOnlineCredentials credentials = new SharePointOnlineCredentials(userName, securePassWord);
                return credentials;

    Thursday, December 1, 2016 10:30 AM

All replies