Superface

Single File Content

vcs/single-file-content@1.1.1
3 providers

Single File Content

Get the content of the specified file.

Input
Owner
Repo
Path
Ref
Result
Size
Content
Encoding

1.Choose a provider

2.Use SingleFileContent with mock in your code

Below instructions are for our Node.js SDK. Use OneService for other languages.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });

async function run() {
  // Load the profile
  const profile = await sdk.getProfile('vcs/single-file-content@1.1.1');

  // Use the profile
  const result = await profile
    .getUseCase('SingleFileContent')
    .perform({
      owner: 'superfaceai',
      repo: 'one-sdk-js',
      path: '/README.md',
      ref: 'c5e4d76'
    }, {
      provider: 'mock'
    });

  // Handle the result
  try {
    const data = result.unwrap();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

run();

Structure details

Input (object)

owner
Owner of the repository
repo
Repository name
path
Path to file at repository
ref
Branch eg. main

Example

{
  "owner": "superfaceai",
  "repo": "one-sdk-js",
  "path": "/README.md",
  "ref": "c5e4d76"
}

Result (object)

size
Size of content according to used provider
content
Content of file
encoding
Used encoding

Example

{
  "size": 5,
  "content": "0.a4ba399d443d3",
  "encoding": "base64"
}

Implementation details

Provider
mock
Use case
SingleFileContent
Author
@superface
Source
Verified