Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to verify file properties on GitHub?

I have a file in a private GitHub repository that contains several properties, such as ‘status=operational’. How can I verify that the ‘status’ property is correctly set to ‘operational’?

Is there an API or library available that can read and verify the content of a file stored in a GitHub repository?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

For a private repository try this

private static readonly string SERVER_URL = $"https://raw.githubusercontent.com/{GITHUB_OWNER}/{GITHUB_REPO}/main/";

private static string GetFileContentFromGitHub(string fileName)
{
    var webRequest = (HttpWebRequest)WebRequest.Create(SERVER_URL + fileName);
    webRequest.Headers.Add(HttpRequestHeader.Authorization, "token " + GITHUB_TOKEN);
    webRequest.Method = "GET";

    using (var response = webRequest.GetResponse())
    {
        using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) 
        {
            return reader.ReadToEnd();
        }
    }
    
}

You can create a GitHub token under the developer settings.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading