lighthouse

package
v0.0.0-...-7cc6c5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPFSGateway = "https://gateway.lighthouse.storage/ipfs/"
)

Variables

View Source
var (
	ZipChunkSize = 200 // MB
	BASH_EXEC    = getBashExecutable()
	THREADS      = runtime.NumCPU() - 1
)

Functions

func Cid

func Cid(data []byte) string

func DownloadChunkedData

func DownloadChunkedData(hash string, modelDir string) (string, error)

func DownloadDataSimple

func DownloadDataSimple(hash string) ([]byte, string, error)

func DownloadDataSimpleFromLighthouse

func DownloadDataSimpleFromLighthouse(hash string) ([]byte, string, error)

func DownloadFileFromLightHouse

func DownloadFileFromLightHouse(hash string, hfDir string) error

func DownloadToFile

func DownloadToFile(hash string, filePath string) error

func UploadData

func UploadData(apikey, fileName string, data []byte) (string, error)

func UploadDataFileByUrl

func UploadDataFileByUrl(ctx context.Context, apikey, rawUrl string) (string, error)

func UploadDataWithRetry

func UploadDataWithRetry(apikey, fileName string, data []byte) (string, error)

func UploadFile

func UploadFile(apikey, fileName string, filePath string) (string, error)

func UploadFileInMultiplePartsToLightHouse

func UploadFileInMultiplePartsToLightHouse(fileFolder string, baseDir string, apiKey string) (string, error)

func WriteFile

func WriteFile(name string, data []byte, perm os.FileMode) error

func ZipAndUploadFileInMultiplePartsToLightHouse

func ZipAndUploadFileInMultiplePartsToLightHouse(fileFolder string, baseDir string, apiKey string) (string, error)

Types

type FileDetail

type FileDetail struct {
	Name  string `json:"name"`
	Hash  string `json:"hash"`
	Index int    `json:"index"`
}

type FileInLightHouse

type FileInLightHouse struct {
	Name       string        `json:"name"`
	IsInserted bool          `json:"is_inserted"`
	IsPart     bool          `json:"is_part"`
	CountPart  int           `json:"count_part"`
	Files      []*FileDetail `json:"files"`
}

func ZipAndUploadFileInMultiplePartsToLightHouseByUrl

func ZipAndUploadFileInMultiplePartsToLightHouseByUrl(url string, baseDir string, apiKey string) (*FileInLightHouse, error)

type FileInfo

type FileInfo struct {
	FileSizeInBytes string `json:"fileSizeInBytes"`
	Cid             string `json:"cid"`
	Encryption      bool   `json:"encryption"`
	FileName        string `json:"fileName"`
	MimeType        bool   `json:"mimeType"`
	TxHash          string `json:"txHash"`
	Error           struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

func GetFileInfo

func GetFileInfo(hash string) (*FileInfo, error)

type LightHouseResponse

type LightHouseResponse struct {
	Name string `json:"Name"`
	Hash string `json:"Hash"`
	Size string `json:"Size"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL