2 Answers
- Newest
- Most votes
- Most comments
2
After strugling half a day I found a solution I'd like to share:
function uint8arrayToStringMethod(myUint8Arr) {
return String.fromCharCode.apply(null, myUint8Arr);
}
const client = new AWS.CodeCommit({ region: "us-east-1" });
const config = {
filePath: "myFile.txt",
repositoryName: "myRepo",
commitSpecifier: "myBranch"
};
const file = await client.getFile(config);
const u8str = uint8arrayToStringMethod(file.fileContent);
I am using aws-sdk V3
thanks everyone for your help. M
answered 2 years ago
0
Hi there,
Using the github search feature I was able to find an example on how the read the file contents:
export async function getRawFile( fileName: string, repoName?: string, branchOrTag?: string ): Promise<string | null> { const fileRes = await client.getFile( repoName ?? config.repository, fileName, branchOrTag ); if (!fileRes?.fileContent) { return null; } const buf = Buffer.from(fileRes.fileContent); return buf.toString(); }
The commitSpecifier seems to have to be a commitId in stead of a branchName though.
Regards, Jacco
answered 2 years ago
Relevant content
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 6 days ago
- AWS OFFICIALUpdated 4 years ago
- AWS OFFICIALUpdated a year ago