kubo icon indicating copy to clipboard operation
kubo copied to clipboard

Import file/folder with CID and data

Open RubenKelevra opened this issue 1 year ago • 0 comments

Checklist

  • [X] My issue is specific & actionable.
  • [X] I am not suggesting a protocol enhancement.
  • [X] I have searched on the issue tracker for my issue.

Description

It would be nice if I could supply a CID like a regular SHA hash and a file/folder and the corresponding data and have kubo fetch the necessary metadata for the CID and then import the data from the file.

Rationale

It's pretty common to have an SHA-Sum and a URL currently, to fetch a file. But sometimes the URLs go offline.

If a CID can replace the SHA-Sum the user can download the URL and check the file with Kubo, without replacing any current toolset (except the hashing tool itself).

After the download, kubo could be instructed to import the downloaded file, by supplying the file and the CID to it's cache.

This way other people can fetch the file from the first user, if the URL is no longer available.

Usecase in Lutris

I think that's the perfect usage of Kubo in Lutris, where currently URLs and hashes are in use. The URLs would be fetched once with URL-Store. Which means in theory the data will be available through an IPFS-Node as a HTTP to IPFS proxy. But this will be very slow.

So the obvious the perfect solution would be to fetch the URL, as long as regular HTTP URLs are provided which work, put the data into the cache on the nodes which have downloaded them, to make the data widespread available and if the URL starts to fail just rely on the IPFS-Network for distribution.

Usage

kubo import --file=/path/to/file /ipfs/CID
kubo import --ignore-auxiliary=1 --folder=/path/to/folder/ /ipfs/CID 

(Where --ignore-auxiliary=1 in the folder version would ignore any additional files/folders like .git)

kubo import /ipfs/CID

Would work analog to kubo get where it would search in the ./$CID folder for the file/folder structure.

RubenKelevra avatar Aug 08 '22 12:08 RubenKelevra