
Show HN: Ipfs-dropzone, a subclass of Dropzone.js that publishes to IPFS - fiatjaf
https://github.com/fiatjaf/ipfs-dropzone
======
DiThi
> I don't know how to publish this package in a way all JS transpilers and
> bundlers out there can understand. Please help me.

Don't do this:

    
    
        module.exports = IPFSDropzone
    

Do this (and change documentation accordingly)

    
    
        module.exports = {IPFSDropzone}
    

or to go full ES6 do this

    
    
        export {IPFSDropzone};
    

add the package babel-env and add this script to package.json:

    
    
        "scripts": {
          "prepublish": "node node_modules/babel-cli/bin/babel *.js -d build/"
        },
    

and change main to "build/index.js".

Run "npm run prepublish" to test.

Edit: Now that I think of it, compiling with babel is probably unnecessary.
But it doesn't hurt and can help old setups.

~~~
SEJeff
Why not send a PR?

~~~
toddmatthews
teach a man to fish

~~~
hinkley
Give a man a fire, he's warm for a day. Set a man on fire, and he's warm for
the rest of his life.

~~~
hetspookjee
This is brilliant.

~~~
hinkley
Terry Pratchett, RIP.

------
proaralyst
One thing I've failed to find out about IPFS: who pays for hosting? The user?
Or is it donated by some peers?

~~~
wolfgang42
This is the #1 thing I see people confused about with IPFS. Basically, there's
3 ways for content to become available:

1\. You add the files to your own node. This is how content gets added, but
obviously it only lasts as long as your node is connected to the Internet,
just like an ordinary HTTP server.

2\. Someone views your content using their node. This causes their node to
cache the content temporarily (IIRC for 30 minutes by default) and publish it
to other nodes. In theory, if your content got at least one view every half
hour it could live on in the users' caches forever.

3\. Someone tells their node to _pin_ your content. The node will then keep it
permanently (until they unpin it) and serve it whenever it's connected to the
Internet. Generally they would do this if they believe it's valuable--either
because they want to keep it themselves, or as a public service to make it
available to others (for example, pinning the Turkish Wikipedia to help evade
censorship).

There are also several _pinning services,_ which you can pay to have them pin
your content on their node, in much the same way as you'd pay a hosting
provider to serve your content.

~~~
robto
In this case, it appears the node is in your browser, right? Does it go away
when you close your tab? In which case your link will survive for 30 minutes,
or is it just gone?

~~~
wolfgang42
It looks like ipfs-dropzone is running an in-browser node, which would go away
as soon as you close the tab (since it's just a web page like any other).
Content on IPFS stays available for as long as there's at least one node which
has it and is connected to the network, so how long the link would survive for
depends on whether other nodes have it and how long they will keep it for. If
nothing else has downloaded the content then it will go away; on the other
hand, if someone has pinned it then it will stay forever (or until they unpin
it or go away).

The 30 minute interval would apply to the IPFS gateway that someone else would
use to download your content (generally a standalone process though I believe
there are efforts to make a browser with an embedded gateway). IPFS nodes
automatically publish their cache, effectively making an autoscaling
distributed CDN. However they will only cache content that they have gotten on
behalf of their user; they won't go out and pull random content from the
network to host it.

~~~
roland-s
Man, I typed a whole reply saying basically the same thing but you beat me to
it! To expand a bit further, in this demo app, the "Save" button calls an API
of a pinning service (Eternum), which pins the file on an external node so it
will stay there as long as it's being paid for. Right now most pinning
services require that you pay them to host your file, but the plan for IPFS is
to use something like Filecoin to incentivize pinning. With Filecoin, instead
of paying a single service to host your content, you would put out an order to
the Filecoin network which says "anyone who hosts my file gets $x per GB per
second", along with some settings (e.g. I want minimum 5x copies of my file on
the network). Then, anyone hosting a Filecoin node will automatically fulfill
requests by hosting content in exchange for a cryptocurrency payout. So,
instead of a single hosting service, you are paying the entire network to
automatically host your file in many places at once.

~~~
bringtheaction
Wait, I thought IPFS was P2P. What's this with the payment stuff?

~~~
prophesi
To compare it with torrenting: The only incentives to "seed" a torrent file is
usually just good will, or to build a reputation to get into invite-only
sites.

We lose the latter incentive with IPFS, and so Filecoin is replaced as the new
incentive to give up storage space for the P2P network.

You can still put your content up on IPFS for free, it's just that only your
IPFS node will be hosting the content, and thereby won't be truly
decentralized. You're the only "seeder", so to speak.

~~~
bringtheaction
Thanks. I went to the Filecoin site to see more but it said the same has ended
and to not fall for scam sites. How do I obtain filecoin? When will I be able
to earn filecoin from hosting content for others?

Is hosting content the way that it is mined? Or is mining it something else?

~~~
prophesi
That, I'm not 100% sure about. Filecoin had their ICO, now it just needs to be
implemented with IPFS.

Once implemented, you should be able to buy Filecoin from market exchanges. To
earn it, Filecoin will use two "proofs-of-storage". One is "proof-of-
replication" wherein your IPFS node proves to be replicating data, and "proof-
of-spacetime" wherein your IPFS node proves to have stored said data for a
certain amount of time.

You can read more about from their whitepaper:
[https://filecoin.io/filecoin.pdf](https://filecoin.io/filecoin.pdf)

------
fiatjaf
There was someone (victorbjelkholm) talking about the zoom-out limits of
[https://filemap.xyz/](https://filemap.xyz/) on IRC and I couldn't reply
there:

I've arbitrarily imposed these limits because the purpose of the app is not
for casual visitors to wander around the world browsing everybody's files,
they're supposed to go to specific addresses and browse only their files
there.

This measure will not protect anyone absolutely, since an "attacker" can
easily read the entire database and figure out where are all the files, but it
protects users from 99% of the casual visitors.

------
zubairq
I have to say that DropZone is supercool and this project makes a lot of
sense. We also use Dropzone.js to store files and their Hash values at
VisiFile. A demo is here:

[http://139.162.228.5/](http://139.162.228.5/)

The code is here:
[https://github.com/zubairq/visifile/blob/master/public/index...](https://github.com/zubairq/visifile/blob/master/public/index.html)

------
senoroink
Really cool demo. One suggestion is to make the dropzone more obvious. I
didn't realize you had to scroll down to find the dropzone.

~~~
fiatjaf
Thank you. I'll try to think in a better layout.

------
kvz
Wondering if anybody would be up for adding this to uppy.io

~~~
fiatjaf
The code is amazingly simple: [https://github.com/fiatjaf/ipfs-
dropzone/blob/8d7d8808ba578a...](https://github.com/fiatjaf/ipfs-
dropzone/blob/8d7d8808ba578a265aa92e14912959c712903cc4/index.js)

If someone knows where to plug into Uppy's upload function then it should be
really easy.

