ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.03k stars 3k forks source link

Disabling default pinning when adding files via API #5178

Open ambertch opened 6 years ago

ambertch commented 6 years ago

It's my understanding that adding automatically does a recursive pin, and that this can be disabled in the cli command by setting pin=false.

If there is a ipfs daemon serving as a gateway where any type of client can upload/add files, how I can disable pinning?

I see that the default is to pin in both the JS and Go APIs (https://github.com/ipfs/js-ipfs/blob/master/src/core/components/files.js#L95 , https://github.com/ipfs/go-ipfs/blob/master/core/commands/add.go#L116) and so my thought is that the only way to do this (without modifying the source code) would be to rewrite incoming requests, ex:

/api/v0/add to /api/v0/add?pin=false

Thanks!

Stebalien commented 6 years ago

If there is a ipfs daemon serving as a gateway where any type of client can make requests to add files, how I can disable pinning?

Files fetched through the gateway (or ipfs get for that matter) will not automatically be pinned. We only do that automatically for files added by the user as users generally expect explicitly added files to not be deleted. Otherwise, files are just cached until they're garbage collected.

Note: To allow users to explicitly add files, you can make the gateway writeable (without exposing the API). Users can add files by calling POST/PUT. However, I'm not sure how to correctly add directories this way...

Usually, I just add the files to my local node and then call the ipfs refs -r THING on the gateway to force it to cache my files. I'm not sure if there's a better way.

ambertch commented 6 years ago

Thanks @Stebalien - yes, I am actually just talking about files uploaded through the gateway. The idea is that I will allow anyone to upload or get content (as a community service), but I only want to pin specific content (the pinning will be done out of band). The idea is that doing direct pins on members of a dataset, that dataset will be guaranteed to be available when there is a high volume of traffic on the gateway.