Skip to content

A Golang SDK for the MetaArk, providing an easy interface for developers to backup the data to Filecoin network. It streamlines the process of securely storing, retrieving, and recovering data on the IPFS and Filecoin network.

Notifications You must be signed in to change notification settings

FogMeta/go-mc-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-mc-sdk

Made by FogMeta Twitter Follow standard-readme compliant

A Golang SDK for the MetaArk product, providing an easy interface for developers to deal with the Filecoin network. It streamlines the process of securely storing, retrieving and recovering data on the IPFS and Filecoin network.

MetaArk is a Web3 data service that securely stores data backups and enables data recovery. It automatically records data storage information and stores data on both the IPFS gateway and Filecoin network, providing fast retrieval and permanent backup.

Features

go-mc-sdk provides the following features:

  • Upload files or directories to the IPFS gateway
  • Report data information to the Meta-Client server
    • MetaArk will automatically complete data processing(split or merge file and generate CAR files)
    • Store the CAR file in the IPFS gateway
    • Send CAR files to the storage providers in the Filecoin network
  • Download files or directories to the local machine
  • Query the dataset list and details by the dataset name
  • Get a source file information by the IPFS CID
  • Acquire the storage information and status of the dataset.

Prerequisites

Before using go-mc-sdk, you need to install the following services:

  • Aria2 service (used to download file)
sudo apt install aria2 

Installation

To install go-mc-sdk, run the following command:

go get github.com/FogMeta/go-mc-sdk

Usage

    key := "V0schjjl_bxCtSNwBYXXXX"
    token := "fca72014744019a949248874610fXXXX"
    metaClient := client.NewClient(key, token, &client.MetaConf{
        MetaServer: "", // client server
        IpfsApi:"",     // for upload
        IpfsGateway:"", // for download
        Aria2Conf:&client.Aria2Conf{ // for download
            Host:"",
            Port:"",
            Secret:""
        }
    })

key : Swan API key. Acquire from Swan Platform -> "My Profile"->"Developer Settings".

token: Swan API access token. Acquire from Swan Platform -> "My Profile"->"Developer Settings".

UploadFile uploads file to the IPFS server, support file & directory

    ipfsData, err := metaClient.Upload("./testdata")

BackupFile backups uploaded files with the given datasetName

    err = metaClient.Backup("dataset-name", ipfsData)

Download downloads files related with ipfsCid to outPath, support download specific url to outPath

    err := metaClient.Download(ipfsCid, outPath)              // download all files related with ipfsCid to outPath
    err := metaClient.Download(ipfsCid, outPath, downloadUrl) // download specific url to outPath

List lists files related with the backup datasetName

    pageNum := 0 // start from 0
    pageSize := 10
    datasetListPager, err := metaClient.List("dataset-name", pageNum, pageSize)

ListStatus lists the status of files related with the backup datasetName & ipfsCid

    pageNum := 0 // start from 0
    pageSize := 10
    datasetListPager, err := metaClient.ListStatus("dataset-name", ipfsCid, pageNum, pageSize)

Rebuild rebuilds the backup dataset files

    list, err := metaClient.Rebuild(datasetId, ipfsCids...)

API Documentation

For more details, please check out the API Documentation.

Contributing

Contributions to go-mc-sdk are welcome! If you find any errors or want to add new features, please submit an Issue, or initiate a Pull Request.

License

go-mc-sdk is licensed under the MIT License.

About

A Golang SDK for the MetaArk, providing an easy interface for developers to backup the data to Filecoin network. It streamlines the process of securely storing, retrieving, and recovering data on the IPFS and Filecoin network.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages