A Git LFS client library implemented in R, compatible with the Giftless Git LFS server.
You can install giftlessclient
from GitHub with:
devtools::install_github("datopian/giftlessclient")
To use giftlessclient
you need to set up your lfs server URL in a environment variable:
Sys.setenv("LFS_SERVER_URL" = 'https://www.my-lfs-server.com')
file_path <- "~/Documents/large-file.bin"
repository <- "repository"
dataset <- "large-dataset"
authz_token <- "eyJ0eXAiOiJK.eyJleHAiOjE2.WOalwa58Wr7_q3zm"
resp <- lfs_upload(file_path, repository, dataset, authz_token, transfer=c('multipart-basic'))
file_path
: a readable, seekable file-like objectrepository
,dataset
: used to generate the prefix for the batch request in formrepository/dataset
authz_token
: Bearer token required by the server
Returns two files attributes: sha256
of the file and it's size
> resp
$sha256
[1] "06c2e256b425f0222db6f14386aa827135043a0645f98e734d3c5cb2999e883f"
$size
[1] "51"
>
file_path <- "~/Documents/my-small-csv.csv"
repository <- "repository"
dataset <- "small-dataset"
authz_token <- "eyJ0eXAiOiJK.eyJleHAiOjE2.WOalwa58Wr7_q3zm"
lfs_upload(file_path, repository, dataset, authz_token, transfer=c('basic'))
The transfers
parameter is optional, and represents a list of supported transfer adapters by priority to negotiate with the server; Typically, there is no reason to provide this parameter.
Send a batch request to the LFS server:
lfs_prefix <- 'organization/giftlessclient'
objects <- list(list(oid = '1231231', size = 12313))
authz_token <- "eyJ0eXAiOiJK.eyJleHAiOjE2.WOalwa58Wr7_q3zm"
batch(lfs_prefix, objects, authz_token, transfer = c('multipart-basic'))
lfs_prefix
: add to LFS server url e.g. iflfs_prefix <- "abc"
and client was created with server url ofhttps://www.my-lfs-server.com
then batch request is made by POST tohttps://www.my-lfs-server.com/abc/objects/batch
objects
: a list of objects to upload.oid
: String OID (sha256
) of the LFS object.size
: Byte size of the LFS object. Must be at least zero.
giftlessclient is free software distributed under the terms of the MIT license. See LICENSE for details.
giftlessclient is (c) 2020 Datopian / Viderum Inc.