Skip to content

nhardt/ipfs_post_file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

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

About

Small test of posting a file to ipfs with python using the web api.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages