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

Add files doesn't show up in IPFS local node #14

Closed
zipgenius opened this issue Dec 14, 2022 · 5 comments
Closed

Add files doesn't show up in IPFS local node #14

zipgenius opened this issue Dec 14, 2022 · 5 comments

Comments

@zipgenius
Copy link

zipgenius commented Dec 14, 2022

I'm new to IPFS development and maybe I'm missing something but I can't make to list files in IPFS client list.

I'm using the following code:
string pFile = @"C:\Users\matte\Desktop\dump_languagefiles.pdf"; var ipfs = new IpfsClient(); AddFileOptions options = new AddFileOptions(); options. Pin = true; options.OnlyHash = false; options. Wrap = false; IFileSystemNode ipfsNode = await ipfs.FileSystem.AddFileAsync(pFile, options, default);

But nothing appears here:
image

@Derrick-
Copy link
Contributor

Derrick- commented Dec 29, 2022

From what I can see, the FileSystemApi implementation is incomplete and for the most part does not uses the /files/ commands.

AddFileAsync only adds the file to the node, and returns the FileSystemNode of the file (or directory). You can see that code here, it uses the /add command and not the MFS subsystem api: /files/

It does not actually add it to the MFS files system of the node which might be implemented by a subsequent /files/cp command to hang the file or directory at a specified path.

I would be interested in working on FileSystemApi or collaborating with anyone else interested in getting this working as expected

@Derrick-
Copy link
Contributor

On a second look, FileSystemApi does not support /api/files at all

It has API call to /file/ls which is deprecated which led me to believe that this class was supposed to be talking to the /files api's, it's actually more of a utility class.

The entire MFS command set should be implemented. I suspect that MFS was not yet released at the time of FileSystemApi creation.

A new API interface and class such as MfsApi should probably be implemented. This work would have to be integrated in net-ipfs-core CoreApi as well

@zipgenius
Copy link
Author

This is my workaround for now, assuming pFile is a StorageFile object:

IpfsClient ipfs = new IpfsClient(); using (Stream fStream = await pFile.OpenStreamForReadAsync()) { var response = await ipfs.UploadAsync("add", default, fStream, Path.GetFileName(pFile.Name), new string[] { "to-files", "/" }); dynamic data = JsonConvert.DeserializeObject(response); string jHash = data.Hash; string jName = data.Name; }
Now I can see the file where it is expected to be.

@Maverick1983
Copy link

Sorry, I don't understand if code it's working or not. Can I help?

@Derrick-
Copy link
Contributor

await ipfs.Mfs.WriteAsync now provides the desired functionality

See: https://github.com/ipfs-shipyard/net-ipfs-http-client/pull/16/files#diff-87d5ab27d9c93d3429cfb2fcdc5fcc7005848241ebde52b6474aaec82f493539R169

Close issue @Arlodotexe ?

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

4 participants