Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.21 KB

File metadata and controls

43 lines (32 loc) · 1.21 KB

Playing around with IPFS

The python client libraries for IPFS that I tried were not compatible with the 0.11 version. IPFS exposes a web API though, so I wanted to see if I could do a basic to write to IPFS with a python http client.

Done

Code

#!/usr/bin/python3

import requests
import dumper

# post should look like:
# Abspath: /absolute/path/to/file.txt
# Content-Disposition: form-data; name="file"; filename="folderName%2Ffile.txt"
# Content-Type: application/octet-stream
# 
# ...contents...

files = {'file': open('README.md', 'rb')}
params = { "arg": "/README", "create" : "1"}
r = requests.post('http://localhost:5001/api/v0/files/write', params=params,
        files=files)

dumper.dump(r)

Reference