kubo icon indicating copy to clipboard operation
kubo copied to clipboard

unable to add directories using api

Open lastmeta opened this issue 1 year ago • 1 comments

Checklist

Installation method

ipfs-desktop

Version

c:\>ipfs version --all
Kubo version: 0.14.0
Repo version: 12
System version: amd64/windows
Golang version: go1.18.3

Config

{
  "API": {
    "HTTPHeaders": {
      "Access-Control-Allow-Origin": [
        "https://webui.ipfs.io",
        "http://webui.ipfs.io.ipns.localhost:8080",
        "http://127.0.0.1:5001"
      ]
    }
  },
  "Addresses": {
    "API": "/ip4/127.0.0.1/tcp/5001",
    "Announce": [],
    "Gateway": "/ip4/127.0.0.1/tcp/8080",
    "NoAnnounce": [],
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001",
      "/ip4/0.0.0.0/udp/4001/quic",
      "/ip6/::/udp/4001/quic"
    ]
  },
  "AutoNAT": {},
  "Bootstrap": [
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
    "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
    "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
  ],
  "DNS": {
    "Resolvers": {}
  },
  "Datastore": {
    "BloomFilterSize": 0,
    "GCPeriod": "1h",
    "HashOnRead": false,
    "Spec": {
      "mounts": [
        {
          "child": {
            "path": "blocks",
            "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
            "sync": true,
            "type": "flatfs"
          },
          "mountpoint": "/blocks",
          "prefix": "flatfs.datastore",
          "type": "measure"
        },
        {
          "child": {
            "compression": "none",
            "path": "datastore",
            "type": "levelds"
          },
          "mountpoint": "/",
          "prefix": "leveldb.datastore",
          "type": "measure"
        }
      ],
      "type": "mount"
    },
    "StorageGCWatermark": 90,
    "StorageMax": "10GB"
  },
  "Discovery": {
    "MDNS": {
      "Enabled": true,
      "Interval": 10
    }
  },
  "Experimental": {
    "AcceleratedDHTClient": false,
    "FilestoreEnabled": true,
    "GraphsyncEnabled": false,
    "Libp2pStreamMounting": true,
    "P2pHttpProxy": false,
    "ShardingEnabled": false,
    "StrategicProviding": false,
    "UrlstoreEnabled": false
  },
  "Gateway": {
    "APICommands": [],
    "HTTPHeaders": {
      "Access-Control-Allow-Headers": [
        "X-Requested-With",
        "Range",
        "User-Agent"
      ],
      "Access-Control-Allow-Methods": [
        "GET"
      ],
      "Access-Control-Allow-Origin": [
        "*"
      ]
    },
    "NoDNSLink": false,
    "NoFetch": false,
    "PathPrefixes": [],
    "PublicGateways": null,
    "RootRedirect": "",
    "Writable": false
  },
  "Identity": {
    "PeerID": "12D3KooWGFJATjWgFx93qVcNSe7JgrQkPLtuEeYDeMKJHjEG5uRG"
  },
  "Internal": {},
  "Ipns": {
    "RecordLifetime": "",
    "RepublishPeriod": "",
    "ResolveCacheSize": 128
  },
  "Migration": {
    "DownloadSources": [],
    "Keep": ""
  },
  "Mounts": {
    "FuseAllowOther": false,
    "IPFS": "/ipfs",
    "IPNS": "/ipns"
  },
  "Peering": {
    "Peers": null
  },
  "Pinning": {
    "RemoteServices": {}
  },
  "Plugins": {
    "Plugins": null
  },
  "Provider": {
    "Strategy": ""
  },
  "Pubsub": {
    "DisableSigning": false,
    "Router": ""
  },
  "Reprovider": {
    "Interval": "12h",
    "Strategy": "all"
  },
  "Routing": {
    "Type": "dht"
  },
  "Swarm": {
    "AddrFilters": null,
    "ConnMgr": {
      "GracePeriod": "1m",
      "HighWater": 40,
      "LowWater": 20,
      "Type": "basic"
    },
    "DisableBandwidthMetrics": false,
    "DisableNatPortMap": false,
    "EnableAutoRelay": false,
    "EnableRelayHop": false,
    "Transports": {
      "Multiplexers": {},
      "Network": {},
      "Security": {}
    }
  }
}

Description

Here I'm trying to add a file:

>>> with open('c:\\pin\\testfile1.txt', mode='rb') as f:
...     r = requests.post(url='http://127.0.0.1:5001/api/v0/add?pin=True',
...         files={'testfile1.txt': f})
...
>>> r.json()
{'Name': 'testfile1.txt', 'Hash': 'QmUC3auK9kVx3wbDCHjTbHfuJYD1iWPWdMBEZ6XaeJr893', 'Size': '16'}
>>> r = requests.post(url='http://127.0.0.1:5001/api/v0/cat?arg=QmUC3auK9kVx3wbDCHjTbHfuJYD1iWPWdMBEZ6XaeJr893')
>>> r.text
'has info'
>>> r = requests.post(url='http://127.0.0.1:5001/api/v0/files/ls?long=True')
>>> r.json()
{'Entries': []}
... <enabling filestore and trying again...>
>>> r = requests.post(url='http://127.0.0.1:5001/api/v0/filestore/ls?long=True')
>>> r.text
''

Ok, so it looks like it added the file but it's not there. So I go back to docker desktop and it's not there either under files... but if I go to settings it says "Local Pinning 1"

So it did work... silently. But that was for a single file, pinning a folder through this API is actually kind of a mystery to me. I tried adding multiple files to this command but it failed.

As a side note, I had to change the config manually, this (and every variant I could think of) didn't work either:

>>> requests.post(url='http://127.0.0.1:5001/api/v0/config?arg=Experimental.FilestoreEnabled&bool=true').json()
{'Key': 'Experimental.FilestoreEnabled', 'Value': False}

I'm hoping all my trouble are related to a bad version or something because I'd really like to get some kind of communication with my local ipfs daemon.

lastmeta avatar Aug 08 '22 06:08 lastmeta

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

welcome[bot] avatar Aug 08 '22 06:08 welcome[bot]

2022-09-02 triage conversation: unfortunately the Kubo RPC api does special form encoding. You won't be able to use Python requests library out of the box. Please look at the Kubo RPC clients that are out there. There is https://github.com/ipfs-shipyard/py-ipfs-http-client but it isn't actively maintained. It should serve as a starting place though. (Side: we'll go update that repo now to make it clear that it isn't maintained and that it needs ownership – looking for a maintainer in https://github.com/ipfs-shipyard/py-ipfs-http-client/issues/316)

BigLep avatar Sep 02 '22 16:09 BigLep

@lastmeta aioipfs works with kubo v0.15.0.

pinnaculum avatar Sep 10 '22 18:09 pinnaculum

I don't think there's anything actionable for us here so closing.

guseggert avatar Sep 22 '22 17:09 guseggert