Documentation ¶
Index ¶
- func CalculateFileCid(fileReader io.Reader) (string, error)
- func Fatal(err error)
- func GenerateEncKey(cid, attr string) (encKeyPath string, encKeyBytes []byte, isNew bool, err error)
- func GetCAR(r io.Reader, useDisk bool) (*car.CarV1, error)
- func GuessMediaType(path string) (string, error)
- func MoveFile(sourcePath, destPath string) error
- func RemoveCarTmpDatastore() error
- func Runner(args []string, run RunFunc)
- func TempDir() string
- func Version() string
- type RunFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateFileCid ¶
CalculateFileCid gets the CIDv1 for the given data, the same as IPFS kubo would. It does not load the whole file into memory.
func Fatal ¶
func Fatal(err error)
fatal kills the program if the provided err is not nil, logging it as well.
func GenerateEncKey ¶
func GenerateEncKey(cid, attr string) (encKeyPath string, encKeyBytes []byte, isNew bool, err error)
GenerateEncKey generates a new encryption key for the given CID and attribute and stores it in a file. If the key already exists, it is read from the file.
func GetCAR ¶
GetCAR returns a CARv1 file created from the provided reader. Currently this uses the default IPFS kubo settings under the hood, and so the CIDv1 represented by the CAR file should exactly match the CIDv1 from CalculateFileCid or IPFS kubo every time.
Set useDisk to control whether this function holds the read bytes all in memory or stores them on the disk temporarily.
If useDisk is true, the caller should call RemoveCarTmpDatastore once they are done with the returned *car.CarV1 struct. This will clear the datastore from the disk.
func GuessMediaType ¶
GuessMediaType guesses the media type of a file based on its contents. The 'media_type' attribute should be preferred over this method.
func MoveFile ¶
MoveFile moves the provided file, even if source and dest are part of different file systems.
It is not atomic. os.Rename should be used in favour of this function if it can be guaranteed that source and dest are on the same filesystem, or atomicity is required.
func RemoveCarTmpDatastore ¶
func RemoveCarTmpDatastore() error