-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[FR] ipfs add -w --name
when adding from stdin
#4986
Comments
@Stebalien @magik6k if someone use command "cat",the request cannot get the file name.so can i add a command such as "-w test.txt",the “test.txt” is the file name that user can specify,so we can get the file name instead of a hash string? |
Currently, that command would add the file |
@Stebalien i understand you.And i want solve this problem and i am coding about this feature.In my opinion,i design a new command "-n",it means the filename.we can use this command such as "cat text.txt | ipfs add -w -n "text.txt" ",so i can get the filename from the command.it is ok? |
@Stebalien the reason i design about this is that if i use "cat" to get the file,we cannot get the filename in cmd.request. |
Hey @kjzz, sorry for the delay, are you still interested in fixing this? It would seem to me that the real fix should happen in This is the function in the adder that checks file names, and probably where the |
hello @schomatis ,sorry for delay,i am still interested in fix this issue,and i am working for this.i plan to add --name flag to get file name.do you agree with me? |
Yes, go ahead! Ping me if you have any questions. |
hello,@schomatis i have a question that if we want add two or more files to ipfs,such as |
@kjzz I would start with the simplest solution (at least for this first iteration) of only one name, especially to avoid the scenario of having to check in
We should ask @keks what's the best way to check that |
@schomatis hello, i have finish the simplest solution of one name .You can review in #5399 |
Hey, sorry, I should have been more clear (I forgot how this issue got started), there are two different problems:
Those two problems (although somewhat similar) are not related:
I should have made that distinction from the beginning, I was talking about the 1st problem, which of those do you want to fix? The PR seems more oriented to the 2nd. |
Also, the second problem is a bit more difficult, as it involves the MFS layer in another repo, so I would suggest you start with the first one. |
Phew, good question. The problem is that usually the request will come through HTTP which uses multipart encoding, and looking through the specs there doesn't seem to be a way to check how many files are sent without reading them all. Looks like there aren't even Does that help? |
Thanks, I was only thinking about the CLI case and not HTTP, so maybe we should concentrate on problem 1 for now (data from
How could we achieve just the |
Hello @schomatis ,i want to fix the 2nd problem that you said.
Now if we use the command -w ,we can not define the path name.
In my PR #5399 ,we can use command like this:
|
I just looked into this and it looks like I was wrong and there is no straightforward way to do that, sorry. We could add a helper the |
Hey @kjzz, I think we're still mixing two different issues. The second problem is about naming the anonymous directory included by the flag In the 1st problem that you're trying to fix, we need to detect that the file came from Checking that the filename is an empty string |
hello @schomatis , thanks for explain.My pr #5399 aimed at solving the second problem.And i think it is the simplest way to solve problem.if we add many files with |
Agreed.
The second problem is about the directory name, but you're PR is adding a name to the file, e.g.,
So, forgetting about the 1st/2nd terminology that may be confusing, there are two things without a name:
Which of those would you like to name? Your PR right now seems to be trying to name the file but is adding a check for the |
hello,@schomatis,let us review the issue.
And now test.txt can only be accessed as
but if we did not use command
and use this command,we can access text.txt by
so the difference between two command is the test.txt accessed path.
In my pr #5399 ,
the accessed path is the same as
of course,if we use command such as
so my pr is aimed at to solve problem that when we use |
Yes, I think I get it now, thanks for taking the time to re-explain it to me. My confusion was always related to the use of the To give you some brief (and incomplete) background: all of the IPFS files you manipulate (e.g., with Sorry for the back and forth in this issue, but this has been a great feedback for me on what are some of the obscure points of how do files in IPFS work. One issue that I'm identifying right now is this contradiction between the content-addressable philosophy of IPFS and the location-addressed system of any file system such as Unix. In IPFS everything is first accessed by a hash and then you can resolve links with names in a path, but that path is meaningless unless you have a hash as an anchor to that path (the hash defines in which filesystem you're in, as there is no unique root path in IPFS). |
@schomatis thanks very much for giving some ipfs background,I also very interested MFS.And i have mofidy code by your advice. And i have understand why should drop wrap check.Thank you again.Please help me review my pr #5399 . And I also want to contribute more for ipfs,can you give some task to do?My email is 601172892@qq.com,if you can give some some advice or task,you can emal to me or tell me here(in github).Thanks a lot! |
@schomatis thx.And you mean we can write some file in this pr #5052 ? |
hey @schomatis ,so Should i write some doc about file api following your template in #5052 ? |
Hey @kjzz, #5052 is not much of a useful template at the moment, I would start by opening an issue in the Files API milestone and start documenting there information you find interesting (from a new user perspective) and think that other users would benefit to know (or what part of the code should be better documented), so we can later discuss how to incorporate that in a doc. |
Version information:
Type:
Feature Request
Description:
ipfs add
supports-w
for filename preservation, e.g.ipfs add -w foo.zip
will let you access the result as/ipfs/<dir hash>/foo.zip
instead of just/ipfs/<file hash>
. However, it doesn't work very well when reading data from stdin:And now test.txt can only be accessed as
/ipfs/Qmaq9QpAYfjF5sPAeEytKHk9rC3Vcgt6J8PRbCsNk7ypqY/Qme9Z5gJLNsQzVELtHh2oQZfjDugHGvLGuNKVtttGAJYAE
This can be fixed post hoc by creating a new parent object with the right link name (using
ipfs object
or, more conveniently,ipfs files
), but this is awkward, and (if you need the resulting object pinned) slow.It would be much more convenient if you could specify a name for the wrapped object on the command line, and have
ipfs add
create the link with that name.The text was updated successfully, but these errors were encountered: