在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:kjaylee/ios-ipfs-api开源软件地址:https://github.com/kjaylee/ios-ipfs-api开源编程语言:Swift 98.8%开源软件介绍:ios-ipfs-apiA wrapper of the IPFS Client HTTP-API for iOS. Check out the client API reference for the full command reference. TODO
ExampleTo run the example project, clone the repo, and run import Ipfs
//Default base address: "http://127.0.0.1:5001/api/v0"
//Do nothing...
//Or
Ipfs.shared().setBase(address: "http://your.ipfs.address")
//Or
Ipfs.shared().setBase(address: "http://your.ipfs.address", port: 5001)
//Or
Ipfs.shared().setBase(address: "http://your.ipfs.address", port: 5001, apiVersionPath: "/api/v0")
import Ipfs
import Moya
// /swarm/peers
Ipfs.swarm.peers { (result) in
switch result {
case let .success(moyaResponse):
let data = moyaResponse.data
let statusCode = moyaResponse.statusCode
// do something with the response data or statusCode
print("statusCode: \(statusCode)")
print("result: \(data)")
break
case let .failure(error):
// this means there was a network failure - either the request
// wasn't sent (connectivity), or no response was received (server
// timed out). If the server responds with a 4xx or 5xx error, that
// will be sent as a ".success"-ful response.
print("failure: \(error.localizedDescription)")
break
}
}
import Ipfs
import Moya //pod 'Moya/RxSwift'
import RxSwift
let service = IAService.swarmPeers(arguments: nil)
let queue = DispatchQueue(label: service.path, qos: .utility, attributes: [.concurrent])
Ipfs.shared().rx.request(MultiTarget(service), callbackQueue: queue)
.filterSuccessfulStatusCodes()
.map(ResponseSwarmPeersModel.self)
.subscribe(onSuccess: { (model) in
print("model count: \(model.peers?.count ?? 0)")
print("model peers: \(String(describing: model.peers ?? nil))")
}) { (error) in
print("failure: \(error.localizedDescription)")
}.disposed(by: disposeBag)
Requirements
InstallationIpfsApi is available through CocoaPods. To install it, simply add the following line to your Podfile: pod 'IpfsApi' Test environment setuphttps://github.com/ipfs/go-ipfs)Docker usage(An IPFS docker image is hosted at hub.docker.com/r/ipfs/go-ipfs.
To make files visible inside the container you need to mount a host directory
with the
Start a container running ipfs and expose ports 4001, 5001 and 8080:
Watch the ipfs log:
Wait for ipfs to start. ipfs is running when you see:
You can now stop watching the log. Run ipfs commands:
For example: connect to peers
Add files:
Stop the running container:
Authorkjaylee, [email protected] LicenseIpfsApi is available under the MIT license. See the LICENSE file for more info. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论