Commit ee3ea80b authored by Vitaly Lipatov's avatar Vitaly Lipatov

eget: add ipfs_get_real_url and use it for gateway mode

parent cbf3f0f2
......@@ -626,14 +626,19 @@ elif [ "$ipfs_mode" = "local" ] ; then
elif [ "$ipfs_mode" = "gateway" ] ; then
info "Will use eget $IPFS_GATEWAY/HASH"
ipfs_get()
ipfs_get_real_url()
{
[ -n "$IPFS_GATEWAY" ] || fatal "ipfs http gateway is not set"
# FIXME:
echo "$IPFS_GATEWAY/$1"
}
ipfs_get()
{
if [ -n "$2" ] ; then
docmd eget -O "$2" "$IPFS_GATEWAY/$1"
docmd eget -O "$2" "$(ipfs_get_real_url "$1")"
else
docmd eget "$IPFS_GATEWAY/$1"
docmd eget "$(ipfs_get_real_url "$1")"
fi
}
......@@ -655,6 +660,11 @@ fi
if [ -n "$IPFS_CMD" ] ; then
ipfs_get_real_url()
{
return 1
}
ipfs_get()
{
[ -n "$IPFS_CMD" ] || fatal "ipfs api is not usable"
......@@ -826,6 +836,8 @@ url_get_real_url()
{
local URL="$1"
local CID="$(cid_from_url "$URL")"
# if we use gateway, return URL with gateway
ipfs_get_real_url "$URL" && return
get_url_by_cid "$CID"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment