Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to upload file to ipfs and get it from ipfs. #167

Open
billqu01 opened this issue Aug 30, 2022 · 0 comments
Open

how to upload file to ipfs and get it from ipfs. #167

billqu01 opened this issue Aug 30, 2022 · 0 comments

Comments

@billqu01
Copy link

my code below, I upload a file to ipfs, then I want to get the file context, but I get nothing.

public partial class Form1 : Form
{
IpfsEngine ipfs;

    string id;
    public Form1()
    {
        InitializeComponent();
        ipfs = new IpfsEngine(new SecureString());
    }

    private async void UploadData()
    {
        

        var options = new AddFileOptions { OnlyHash = true };
        var fsn = await ipfs.FileSystem.AddFileAsync("d://temp/1.txt", options);

        //var text = await ipfs.FileSystem.ReadAllTextAsync(fsn.Id.ToString());

        MessageBox.Show((string)fsn.Id);

        id = fsn.Id;

    }

    private async void GetData()
    {
        //Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD


        string filename = id;
        var text = await ipfs.FileSystem.ReadAllTextAsync(filename);
        

        MessageBox.Show(text);

        
    }

    private void button1_Click(object sender, EventArgs e)
    {
        UploadData();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        GetData();
    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant