I want to download a single LFS file from gitLab using c#. Currently I have the following:
string pkgUri = $"{projectURL}files/{pgkFilePath}/raw?private_token={projectToken}&ref=master";
string pkgResult = await client.GetStringAsync(pkgUri);
/*
result:
DATA: version https://git-lfs.github.com/spec/v1
oid sha256:h2d00e87q97a965c6b125ce3ee2fe35ea4e66c12345w7129740bd40645a3bbd0
size 812345
*/
In my research I came across this link, which is helpful.
https://gitlab.com/gitlab-org/gitlab/-/issues/27892#note_395085312
But I'm having a hard time setting this up in c#:
# request actions for given lfs objects
LFS_OBJECT_REQUEST_JSON="$(jq -rnc --arg oid $OID --arg size $SIZE --arg ref "refs/heads/$BRANCH" '{"operation":"download","objects":[{"oid":$oid,"size":$size}],"transfers":["lfs-standalone-file","basic"],"ref":{"name": $ref }}')"
LFS_OBJECT_ACTION_DOWNLOAD="$(set -o pipefail; curl -sSlf -H "Content-Type: application/json" -X POST -d "$JSON" "https://oauth2:${GITLAB_TOKEN}@gitlab.com/${PROJECT}.git/info/lfs/objects/batch" | jq -er '.objects[0].actions.download')"
Here's what I've attempted and I'm able to get the oid and size. Any help would be greatly appreciated.
AssetEntry pkgEntry = JsonConvert.DeserializeObject<AssetEntry>(pkgResult);
string size = pkgEntry.size;
string oid = pkgEntry.content_sha256;
Console.WriteLine($"OID: {oid}\nSIZE: {size}"); // This works
//Get package
string downloadLFS = $"{projectURL}info/lfs/objects/{oid}?private_token={projectToken}&ref=master";