Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Known implementations #101

Closed
muliyul opened this issue Sep 26, 2021 · 4 comments
Closed

Known implementations #101

muliyul opened this issue Sep 26, 2021 · 4 comments
Labels

Comments

@muliyul
Copy link

muliyul commented Sep 26, 2021

Is there a section with known implementations for this? (*Manager classes?)

@slonopotamus
Copy link
Collaborator

slonopotamus commented Sep 26, 2021

See https://github.com/bozaro/git-as-svn/tree/master/src/main/kotlin/svnserver/ext/gitlfs/server

@muliyul
Copy link
Author

muliyul commented Sep 27, 2021

I want to use this for s3 storage but not sure how to go about this.

@muliyul
Copy link
Author

muliyul commented Sep 30, 2021

@slonopotamus What is the "object hash" I need to pass to the client in order to download a blob? Is it the hash of the content? hash of the commit?

@slonopotamus
Copy link
Collaborator

slonopotamus commented Sep 30, 2021

It's the hash of LFS object from pointer file.

So if you have, for example, this file:

version https://git-lfs.github.com/spec/v1
oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393
size 12345

Then hash is 4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393.

You can use ru.bozaro.gitlfs.pointer.Pointer#parsePointer and ru.bozaro.gitlfs.pointer.Pointer#serializePointer to save/load pointer files.

So, the whole procedure is something like this (plus various error handling):

val OID_PREFIX = "sha256:"

val bytes = ...; // Read pointer file from somewhere
val lfsClient = ...; // Construct client

val pointer = Pointer.parsePointer(bytes, 0, length)!!
val oid = pointer[Constants.OID]
val size = pointer[Constants.SIZE].toLong()
val hash: String = oid.substring(OID_PREFIX.length)

val dataStream = lfsClient.openObject(hash)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants