Single File Content

vcs/single-file-content@1.1.1
Supported by 3 providers
B
G
G

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

npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

const sdk = new SuperfaceClient();

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