How to add some file to a hash folder fast?

From @cxgreat2014 on Sat Dec 17 2016 01:26:48 GMT+0000 (UTC)

I had used ipfs add -r folder_name to add a folder already, folder hash is QmNbs8stghYQMSTiC28aonneZHAk2dTJmMehJLJWR3xY7u, now I want to add some new file to this hash folder fast (not generate other file’s hash), how can I do it?

Copied from original issue:

From @whyrusleeping on Sat Dec 17 2016 18:52:15 GMT+0000 (UTC)

@cxgreat2014 You can use ipfs object patch.

For example, if you wanted to add a file named foo to your directory, whose hash is QmABC123, you could run:

ipfs object patch QmNbs8stghYQMSTiC28aonneZHAk2dTJmMehJLJWR3xY7u add-link foo QmABC123

From @Kubuxu on Sat Dec 17 2016 21:26:27 GMT+0000 (UTC)

Or using files API:

ipfs files cp /ipfs/OLDDIRHASH /tmpdir
ipfs files cp /ipfs/NEWFILE /tmpdir/newfile
NEWHASH=$(ipfs files stat --hash /tmpdir)
ipfs pin add $NEWHASH
ipfs files rm -r /tmpdir

From @cxgreat2014 on Sun Dec 18 2016 02:09:19 GMT+0000 (UTC)

@whyrusleeping @Kubuxu Thanks a lot