I am looking for some kind of naming / describtion system that gives me a summary about my local file hashes. I am not talking about ipns. I am just looking for a way to get a quick summery about my hashes (like a titel in a google docs, some kind of sticky note or maybe some tags that describe the content of the hashes) - I only want to make it easier to remember content of hashes + I think it will help a lot once I start to get a bunch of hashes
I am only looking for a system that is visible to me, but I guess it could be build upon.
At some point there will surely be a GUI file manager/browser for the Files API. But the latter is already a great feature on the command line. You can also make a shell alias to auto-create a reference to any new objects in your mutable FS, e.g. something like this:
ipfadd() {
if [[ $(ipfs 2>/dev/null) == "" ]] ; then
echo -e "IPFS is either not installed or not in your \$PATH"
return 1
fi
if [[ $(ps aux | grep "ipfs daemon" | grep -v "grep.*ipfs daemon" 2>/dev/null) == "" ]] ; then
echo -e "IPFS daemon is not running"
return 1
fi
if [[ $# -eq 0 ]] ; then
echo -e "No file specified.\nUsage:\tipfadd <file>"
return 1
fi
for file in "$@"
do
if [[ ! -d "$file" ]] ; then
hash=$(ipfs add -Q "$file")
echo -e "Added file: $hash"
else
hash=$(ipfs add -Q -r "$file")
echo -e "Added directory: $hash"
fi
filename=$(basename "$file")
if [[ $(ipfs files ls | grep "^$filename$") != "" ]] ; then
ext="${filename##*.}"
name="${filename%.*}"
current_date=$(date -u +"%Y%m%d-%H%M%S")
filename="$name-$current_date.$ext"
fi
ipfs files cp /ipfs/$hash /"$filename"
mfs_row=$(ipfs files ls -l | grep "^$filename")
echo -e "Copied: $mfs_row"
done
echo -e "Done."
}
You can also add it to a mutable directory, e.g. /fresh, then use ipfs files cp /ipfs/$hash /fresh/"$filename" and mfs_row=$(ipfs files ls -l /fresh | grep "^$filename")
PS: the alias doesn’t check, if the filename is already in use in your MFS target directory, so you probably need to list that target directory first (without the -l option) and grep "^$filename$", and if the result != "", then add a string to your filename, e.g. the current date etc., and only then run ipfs files cp.
EDIT 1: added check for “file exists” (macOS/BSD date format)
EDIT 2: added file vs dir check