2

I am trying to automate some stuff that will require to get the current images from a GitHub private repo.

Ideally, I'd iterate over the root directory and, for all images, get the URL for the RAW file.

For example:

If the URL is not available, I could get around with getting the binary content. However, I couldn't find a way to do that either.

As an example, this is basically how I am "finding" files that I want de details of.

{
  repository(owner: "Flow2015", name: "logo") {
    name
    object(expression: "master:") {
      ... on Tree {
        entries {
          name
          object{
            ... on Blob {
              text
            }
          }
        }
      }
    }
  }
}

I understand that I could build the URL using Repo/branch/filename, I'm just trying to find a safe way if there is one.

luigibertaco
  • 1,112
  • 5
  • 21
  • I don't believe those are intended to be used programmatically which is why the API doesn't provide the URLs. If you need to fetch many individual objects from a repo, you'd be better off with a shallow clone, which will be faster. – bk2204 Aug 31 '20 at 02:07
  • It can be done using REST api, but as I already use the GraphQL for other reasons, I was trying to use it for that too. https://docs.github.com/en/rest/reference/repos#contents – luigibertaco Aug 31 '20 at 03:33
  • by separate `object(expression ...)` ? https://stackoverflow.com/a/46254836/6124657 ... but in graphql/json it will be encoded, at least not optimal .. build url – xadm Aug 31 '20 at 05:30
  • 1
    Unfortunately, the text doesn't include binary content for non-text files. At least I couldn't find a way to make it return anything for images or other binary types. – luigibertaco Aug 31 '20 at 06:01
  • ... like files in e-mails (or storing images in DB), possible, doable, usable for small sizes but HIGHLY innefective (output size, processing costs) at scale ... and uneccessary – xadm Aug 31 '20 at 06:09
  • I agree with everything you said, would be happy if the data source for my need were not GitHub projects, however, that's what I have to work with. The REST API provides the content and URL, I am just checking if the GraphQL API has the same feature. – luigibertaco Aug 31 '20 at 06:15
  • some parts, usually covered by apis (but de facto handled using browser behaviour), are out of scope of graphql (pure data structures) and needs to be handled other ways (no redirects, no content types etc. - just json response) – xadm Aug 31 '20 at 06:36

0 Answers0