gnfiles

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: MIT Imports: 8 Imported by: 0

README

GNfiles allows to download/restore/update files used in GlobalNames projects

Working with multiple large files is cumbersome. To make it easier to download, upload, and update files using a standard approach (IPFS in this case) allows to keep data decentralized and reused with more ease.

This program is an exploration how to utilize features availabe at IPFS for transferring files.

Usage

Currently the app depends on running IPFS node on a local computer. Install IPFS and run:

ipfs daemon &
Upload directory to IPFS

A directory can by uploaded to IPFS if IPFS node is runnin locally. Optionally, you can set a permalink using IPNS keys.

# To sync a directory to IPFS without permalink
gnfiles sync some_dir

# To sync a directory to IPNS with permalink (takes about a minute)
gnfiles sync somedir ipns-name

# You can find available key names with
ipfs key list
Get directory from IPFS

The program rebuilds directory structure getting a meta-data file with information about paths and files. In general it works as the following:

Files can be downloaded from anywhere, assuming that they are available. If there are only available on one node, that node has to be running.

gnfiles get [source] [destination]

Where the source is a place to get metafile, and destination is a local directory, probably empty, where to download all the files. If files with the same name exist already, they will be overwritten.

# get metadata from local file system
gnfiles get /some/dir/_META.json target_dir

# get metadata from a url
gnfiles get https://ipfs.io/ipfs/Qmhash target_dir

# get metadata from an IPFS path (requires local IPFS node)
gnfiles get /ipfs/Qmhash target_dir
gnfiles get /ipns/k5hash target_dir

# get metadata from a CID (requires local IPFS node)
gnfiles get Qmhash target_dir

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "v0.0.1"

Functions

func PrepareDir

func PrepareDir(s string) string

Types

type Config

type Config struct {
	ApiURL     string
	KeyName    string
	Source     string
	Dir        string
	WithUpload bool
}

func NewConfig

func NewConfig(opts ...Option) *Config

type GNfiles

type GNfiles interface {
	Download() error
	Upload() error
	Version() gnvers.Version
}

func New

func New(cfg *Config) GNfiles

type Option

type Option func(*Config)

func OptApiURL

func OptApiURL(s string) Option

func OptDir

func OptDir(s string) Option

func OptKeyName

func OptKeyName(s string) Option

func OptSource

func OptSource(s string) Option

Directories

Path Synopsis
ent
cmd
io
fs

Jump to

Keyboard shortcuts

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