Documentation ¶
Overview ¶
Package storage provides functions for adding files to IPFS.
Package storage provides functions for fetching files from IPFS.
Index ¶
- Constants
- func AddFile(ctx context.Context, config *config.Config, ipfsAPI icore.CoreAPI, ...) (path.ImmutablePath, error)
- func AddFileMetadataToRegistry(config *config.Config, fileCid path.ImmutablePath, filePath string) error
- func ChangeStorageMax(nodeIpfs *core.IpfsNode, memorySpace uint) (bool, error)
- func ConnectToPeers(ctx context.Context, ipfs icore.CoreAPI, peers []string) error
- func DeleteFile(fileName string) error
- func FreeMemoryAvailable(ctx context.Context, nodeIpfs *core.IpfsNode) (uint64, error)
- func GetBlock(log *ipfsLog.ZapEventLogger, ctx context.Context, ipfsAPI icore.CoreAPI, ...) (*block.Block, error)
- func GetDirectoryWithPath(ctx context.Context, ipfsAPI icore.CoreAPI, directoryFile path.ImmutablePath, ...) error
- func GetFile(ctx context.Context, config *config.Config, ipfsAPI icore.CoreAPI, ...) error
- func MemoryUsed(ctx context.Context, nodeIpfs *core.IpfsNode) (uint64, error)
- func MoveFile(source, destination string) error
- func PinFile(ctx context.Context, ipfsAPI icore.CoreAPI, fileCid path.ImmutablePath) (bool, error)
- func PrepareFileForIPFS(path string) (files.Node, error)
- func PublishBlock(log *ipfsLog.ZapEventLogger, ctx context.Context, config *config.Config, ...) bool
- func RemoveFileMetadataFromRegistry(config *config.Config, fileCid path.ImmutablePath) error
- func SpawnNode(ctx context.Context, cfgg *inconfig.Config) (icore.CoreAPI, *core.IpfsNode, error)
- func UnpinFile(ctx context.Context, ipfsAPI icore.CoreAPI, fileCid path.ImmutablePath) (bool, error)
- type FileMetadata
- type MetadataRegistry
Constants ¶
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 ChangeStorageMax ¶
* MEMORY SHARE TO THE BLOCKCHAIN BY THE NODE
func ConnectToPeers ¶
This function allows a node to connect to other peers given in an IPFS network
func DeleteFile ¶
This function allows to delete a file from IPFS, and from the storer node (precisely unpin it)
func FreeMemoryAvailable ¶
func GetBlock ¶
func GetBlock(log *ipfsLog.ZapEventLogger, ctx context.Context, ipfsAPI icore.CoreAPI, blockPath path.ImmutablePath) (*block.Block, error)
GetBlock retrieves a block from IPFS using the provided CID.
func GetDirectoryWithPath ¶
func GetDirectoryWithPath(ctx context.Context, ipfsAPI icore.CoreAPI, directoryFile path.ImmutablePath, downloadPath string) error
GetDirectoryWithPath download a directory using its CID (Content Identifier). It creates the necessary directory if it doesn't exist and writes the file to a specified path.
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 MoveFile ¶
MoveFile moves a file from the source path to the destination path. It returns an error if the move operation fails.
func PrepareFileForIPFS ¶
prepareFileForIPFS prepares a file to be added to IPFS by creating a UnixFS node from the given path. It retrieves file information and creates a serial file node for IPFS.
func PublishBlock ¶
func PublishBlock(log *ipfsLog.ZapEventLogger, ctx context.Context, config *config.Config, nodeIpfs *core.IpfsNode, ipfsApi icore.CoreAPI, b *block.Block) bool
PublishBlock publishes a block to IPFS and adds its metadata to the registry.
func RemoveFileMetadataFromRegistry ¶
func RemoveFileMetadataFromRegistry(config *config.Config, fileCid path.ImmutablePath) 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.