https://github.com/alexfreska/elixir_skynet
Elixir client for uploading and downloading files from Sia Skynet
https://github.com/alexfreska/elixir_skynet
cdn data elixir sia sia-skynet skynet storage
Last synced: about 1 year ago
JSON representation
Elixir client for uploading and downloading files from Sia Skynet
- Host: GitHub
- URL: https://github.com/alexfreska/elixir_skynet
- Owner: alexfreska
- Created: 2020-02-17T21:47:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-24T15:14:01.000Z (over 6 years ago)
- Last Synced: 2024-04-27T10:21:06.297Z (about 2 years ago)
- Topics: cdn, data, elixir, sia, sia-skynet, skynet, storage
- Language: Elixir
- Homepage:
- Size: 524 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Unofficial Elixir client for uploading and downloading files from Sia Skynet.
## Installation
The package can be installed by adding `skynet` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:skynet, "~> 0.1.6"}
]
end
```
## Usage
```elixir
# Download a file using its Skylink
iex> Skynet.download("AADOl5bb0oXpmIWOK115bctmbV9Jogl-FcyMmIzb5MV1ZA")
{:ok,
%{
file: <<79, 103, 103, 83, 0, 2, 0, 0, 0, ...>>,
filename: "Bach_Fugue_in_A-minor_BMW_543.opus"
}
}
# Upload a file by providing its path
iex> Skynet.upload("path/to/file.jpeg")
{:ok,
%{
skylink: "AACEIgsvJKk7yY2y9Z-dXTh5niUAKwO_jH4LpbLiaw5X1g",
# In addition to the Skylink, the merkleroot and bitfield are also returned for convenience
merkleroot: "84220b2f24a93bc98db2f59f9d5d38799e25002b03bf8c7e0ba5b2e26b0e57d6",
bitfield: 0
}
}
# Configure options, like the target portal URL
iex> Skynet.upload("path/to/file.jpeg", portal_url: "https://skydrain.com")
{:ok,
%{
skylink: "AACEIgsvJKk7yY2y9Z-dXTh5niUAKwO_jH4LpbLiaw5X1g",
merkleroot: "84220b2f24a93bc98db2f59f9d5d38799e25002b03bf8c7e0ba5b2e26b0e57d6",
bitfield: 0
}
}
```
The documentation can be found at [https://hexdocs.pm/skynet](https://hexdocs.pm/skynet).
