Upload and Download Files
Bee provides a convenient way of uploading your data into the Swarm. Once your data has been uploaded, it will be distributed and stored by a worldwide network of p2p nodes, and made available from Swarm's web gateways.
#
Quick UploadOnce your Bee node is running, a HTTP API is enabled for you to interact with. The command line utility curl is a great way to interact with a Bee node's API.
First, let's check to see if the API is running as expected...
Once running, a file can be uploaded by making an HTTP POST request to the files
endpoint of the Bee API.
We may also pass the appropriate mime type in the Content-Type
header, and a file name to the name
query parameter so that the file will be correctly handled by web browsers and other applications.
danger
Data uploaded to the swarm is always public. In Swarm, sensitive files must be encrypted before uploading to ensure their contents always remains private.
When succesful, a json formatted response will be returned, containing a swarm reference or hash which is the address of the uploaded file, for example:
Keep this address safe, as we'll use it to retrieve our content later on.
In Swarm, every piece of data has a unique address which is a unique and reproducible cryptographic hash digest. If you upload the same file twice, you will always receive the same hash. This makes working with data in Swarm super secure!
info
If you are uploading a large file it is useful to track the status of your upload as it is processed into the network. Head over to the advanced usage section to learn how to follow the status of your upload.
Once your file has been completely synced with the network, you will be able to turn off your computer and other nodes will take over to serve the data for you!
#
DownloadOnce your file is uploaded into Swarm, it can be retrieved with a simple HTTP GET request.
Substitute the hash in the last part of the url to be the reference to your own data.
You may even simply navigate to the URL in your browser:
http://localhost:1633/files/042d4fe...2291dd4
#
Public GatewaysTo share files with someone who isn't running a Bee node yet, simply change the host in the link to be one of our public gateways. Send the link to your friends, and they will be able to download the file too!