I uploaded and immediately deleted a file and didnt share it(link) with anyone/other node but the file is still visible with the link. So do all my connected peers listen for me uploading new file? If so do i store other peer’s file chunk too?
The file is still visible just because IPFS caches things until it needs the space (garbage collects), so unless you have “pinned” a file it can be garbage collected at any time automatically, but still may be visible to all IPFS nodes up until it actually is deleted. You don’t have to do anything special to make files visible to all other peers. So they’ll see the cached version of it also.
Thanks for your response. I just want to clarify myself about some points.
“IPFS caches things until it needs the space” where does it caches? in my local hardisk?
And when i upload a file, that file is fragmented into parts and those small parts are persisted in several nodes(local storage of that computer) right?
When you install IPFS on your computer it creates a single folder which holds all the cached files (actually all the parts of files), so when you upload something yourself or request some other files you didn’t upload yourself, they also come into your cache. But yes that cache is a single place inside your IPFS installation. If you were to remove IPFS it all goes away (except what your browser itself may have cached, for example)
Another question, if i upload a file, share the link with someone(not a node) and stop my server, he should not be able to access that file right? but he can!!! how is this happening?
IPFS is similar to BitTorrent in the following way: When someone requests a file it grabs parts of the file from wherever it can find them, to construct the file. Wherever there are enough remnants of a file scattered around that means the file can be found and served up if the original server that uploaded it has been shut down. But you can expect those servers to eventually do garbage collection and if no server is running with the file pinned it will eventually become inaccessible.
I am trying to understand when and how my uploaded file gets “scattered around”? I mean if no node requests for that file ever, that file dosn’t get “scattered around” right? Only when a node requests and gets that file, the file “scattered around” among those 2 nodes, and if 3rd node requests that file, gets scattered parts from both node right?
Right, what you said is basically correct, but technically there’s no guarantee that parts of your file don’t go out to some random nodes that you don’t even know about. It’s a public network. So the correct design logic is to make no assumptions about who has chunks or when or how or why or until when, etc. Shouldn’t matter to you.
I am worried because i want to make a file sharing system with ipfs for my chat application. My concern is for the following case:
- I have uploaded a file and send the file link(https://ipfs.io/ipfs/hash?filename=a.txt) as direct message
- Receiver is currently offline
- Then i go offline for the day
- Receiver comes online but i am offline now
Now can he see the file ? (I am planning to make each chat user a node)
If you’re not running your own gateway that stays up all the time, then you’d have to use a Pinning Service (for example, something like Pinata | Effortless IPFS File Management). Many of them have a very simple API you can call over HTTP (REST), so maybe they will let you register a single API key that is used by all clients… so that only one subscription on Pinata is required.
But even spinning up a Linode instance can be done pretty cheap to run your own gateway.
I am confused now. If i am offline, how do they(pinata) get that file, do they always sync with my computer?
Ideally a Pinning service API should offer at least these two ways of letting someone store data on IPFS:
- upload the actual data, to the service (to pin it)
- let you Pin arbitrary existing CIDs.
So your chat app instances would put data onto IPFS thru the Pinning service, and then can go immediately off line, and the pinning service will be able to serve it up to always.
Thanks a lot, this was great help to me. Btw can you please take a look at this one? Can not access file