ipfs

package
v0.0.0-...-724b7ff Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package storage provides functions for adding files to IPFS.

Package storage provides functions for fetching files from IPFS.

Index

Constants

View Source
const (
	B  = 1
	KB = 1000 * B
	MB = 1000 * KB
	GB = 1000 * MB
)

Variables

This section is empty.

Functions

func AddFile

func AddFile(ctx context.Context, config *config.Config, ipfsAPI icore.CoreAPI, filePath string) (path.ImmutablePath, error)

AddFileToIPFS adds a file to IPFS and returns its CID. It also collects and saves file metadata. The function handles the file addition process and records metadata such as file size, type, name, and user public key.

func AddFileMetadataToRegistry

func AddFileMetadataToRegistry(config *config.Config, fileCid path.ImmutablePath, filePath string) error

func ChangeStorageMax

func ChangeStorageMax(nodeIpfs *core.IpfsNode, memorySpace uint) (bool, error)

* MEMORY SHARE TO THE BLOCKCHAIN BY THE NODE

func ConnectToPeers

func ConnectToPeers(ctx context.Context, ipfs icore.CoreAPI, peers []string) error

This function allows a node to connect to other peers given in an IPFS network

func DeleteFile

func DeleteFile(fileName string) error

This function allows to delete a file from IPFS, and from the storer node (precisely unpin it)

func FreeMemoryAvailable

func FreeMemoryAvailable(ctx context.Context, nodeIpfs *core.IpfsNode) (uint64, error)

func GetFile

func GetFile(ctx context.Context, config *config.Config, ipfsAPI icore.CoreAPI, cidFile path.ImmutablePath) error

GetFile download a file using its CID (Content Identifier). It creates the necessary directory if it doesn't exist and writes the file to a specified path.

func MemoryUsed

func MemoryUsed(ctx context.Context, nodeIpfs *core.IpfsNode) (uint64, error)

func MoveFile

func MoveFile(source, destination string) error

MoveFile moves a file from the source path to the destination path. It returns an error if the move operation fails.

func PinFile

func PinFile(ctx context.Context, ipfsAPI icore.CoreAPI, fileCid path.ImmutablePath) (bool, error)

func RemoveFileMetadataFromRegistry

func RemoveFileMetadataFromRegistry(config *config.Config, fileCid path.ImmutablePath) error

func SpawnNode

func SpawnNode(ctx context.Context, cfgg *inconfig.Config) (icore.CoreAPI, *core.IpfsNode, error)

Spawns a node

func UnpinFile

func UnpinFile(ctx context.Context, ipfsAPI icore.CoreAPI, fileCid path.ImmutablePath) (bool, error)

Types

type FileMetadata

type FileMetadata struct {
	Cid       string    `json:"cid"`       //
	Timestamp time.Time `json:"timestamp"` // Timestamp of when the file was added.
	Size      string    `json:"size"`      // Size of the file in bytes.
	Extension string    `json:"extension"` // L'extension du fichier.
	Name      string    `json:"name"`      // Original name of the file.
}

FileMetaData represents the metadata associated with a file stored in the storage node.

type MetadataRegistry

type MetadataRegistry struct {
	Files []FileMetadata `json:"files"`
}

MetadataRegistry represents a collection of file metadata records.

Jump to

Keyboard shortcuts

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