public bool DownlodFromUrl(int baseUrlId, string url, string filePath, string fileName) { filePath = AuthorizeManager.AuthorizeActionOnPath(filePath .Replace(Config.UrlDelimeter, Helper.RootUrl), ActionKey.WriteToDisk); if (AuthorizeManager.AuthorizeActionOnEntityId(baseUrlId, (int)EntityIdentity.Urls, (int)ActionKey.DownloadFromAddress)) { var baseUrl = _contentManagementContext.MasterDataKeyValues.AsNoTracking() .SingleOrDefault(md => md.TypeId == (int)EntityIdentity.Urls && md.Id == baseUrlId); if (baseUrl == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.CodeNotFound)); } var downloadUrl = ""; if (baseUrl.PathOrUrl[baseUrl.PathOrUrl.Length - 1] == '/') { if (url[0] == '/') { downloadUrl = baseUrl.PathOrUrl + url.Substring(1); } else { downloadUrl = baseUrl.PathOrUrl + url; } } else { if (url[0] == '/') { downloadUrl = baseUrl.PathOrUrl + url; } else { downloadUrl = baseUrl.PathOrUrl + "/" + url; } } if (filePath[filePath.Length - 1] == '/') { filePath += fileName; } else { filePath += "/" + fileName; } _fileSystemManager.DownlodFromUrl(downloadUrl, filePath); } return(true); }