Closed zipgenius closed 1 year ago
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
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
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.
Sorry, I don't understand if code it's working or not. Can I help?
await ipfs.Mfs.WriteAsync now provides the desired functionality
Close issue @Arlodotexe ?
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](https://user-images.githubusercontent.com/547604/207577448-b35e6247-3ad4-419e-9a08-fe39bfabbb94.png)