skynet_ruby 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57575c5a9d188be33f4bb758608834ee9e8b262b13fd72b929d7226c58f1ceca
4
- data.tar.gz: 1ea06346742242072e6c5df5062d518288bd59652bc2f53000e1c6eb47801332
3
+ metadata.gz: 2aaf111151cd358c2b02f697693b9f0bac52ff73c97b76b5829846fe25d2e33f
4
+ data.tar.gz: 3d116cb181c7bceea13e1b6f5a81b43a79cb762c141c5ae1697ed3626c361970
5
5
  SHA512:
6
- metadata.gz: 8c635a7e4106d53ef4be1647081267d5b8ca8f0ec8e3773092c0ec4149e993e09937b70fdfb53aa7329c42a1c9e8e79d90e76a37f17af33a44b0bc0a5c141f4c
7
- data.tar.gz: aa7a3d83372f6348226c9d5527618eb2e4e269b60e1de48c0cbd90daed43304d67c2c40a364fc5b846ae8570fd98a863e32fe5238e944ec8f3c8d9baa08adc75
6
+ metadata.gz: 810807238d68b08e341a4202473fc95e1916e689e2d87bb3d73a7a88476703de99609dbb48f64a6ac038edc179b9ea904d5fb8b797ac4b3f48d834f09a27b705
7
+ data.tar.gz: 3c26e1c721739c1751ac9b12dc9f38f335fc154eb3ee9aadded7b3be713dcd07ced7b8a76ebd46b4bd3d9031dcc254d202f2fb2728059e5c076456dd56ab0e43
data/.gitignore CHANGED
@@ -4,3 +4,4 @@
4
4
  .rspec_status
5
5
  .byebug_history
6
6
  pkg
7
+ .jwt
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- skynet_ruby (0.2.1)
4
+ skynet_ruby (0.3.0)
5
5
  mime-types (~> 3.3.0)
6
6
  multipart_body (~> 0.2.1)
7
7
  typhoeus (~> 1.4.0)
@@ -18,7 +18,7 @@ GEM
18
18
  diff-lcs (1.4.4)
19
19
  ethon (0.14.0)
20
20
  ffi (>= 1.15.0)
21
- ffi (1.15.0)
21
+ ffi (1.15.3)
22
22
  hashdiff (1.0.1)
23
23
  mime-types (3.3.1)
24
24
  mime-types-data (~> 3.2015)
data/README.md CHANGED
@@ -57,6 +57,16 @@ Returns the metadata of an upload. Currently quite often no metadata is returned
57
57
 
58
58
  client.get_metadata "ZAAZyxRQ7ImB_...."
59
59
 
60
+ #### Persisting Files (Upload to an account)
61
+
62
+ Files are by default persisted for 90 days if you upload to skynet. If you have an account files can be pinned endlessly. You can read more [here](https://docs.siasky.net/developer-guides/server-hosted-skynet-usage#file-persistence).
63
+
64
+ To upload an account you need to get a JWT token. You can copy that one from the developer consoles, look for the `skynet-jwt` cookie and copy the value. See [docs](https://docs.siasky.net/developer-guides/server-hosted-skynet-usage#file-persistence).
65
+
66
+ ! JWTs expire after 720 hours and there's no tooling to detect if your JWT is expired.
67
+
68
+ Skynet::Client.new(jwt: "XYZ...)
69
+
60
70
  ## Progress
61
71
 
62
72
  ☑ Uploading a file\
@@ -64,11 +74,13 @@ Returns the metadata of an upload. Currently quite often no metadata is returned
64
74
  ☑ Downloading a file\
65
75
  ☑ Downloading a directory\
66
76
  ☑ Getting Metadata\
77
+ ☑ Uploading Files to an account\
67
78
  ☐ SkyDB\
68
79
  ☐ Registry\
69
80
  ☐ MySky
70
81
 
71
82
 
83
+
72
84
  ## Contributing
73
85
 
74
86
 
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/setup'
3
+ require 'skynet'
4
+
5
+ raise "Please create a .jwt file with you JWT token" unless File.exists?('.jwt')
6
+ raise "Please provide a file name" unless ARGV[0]
7
+ jwt = File.read('.jwt')
8
+
9
+ Skynet::Client.new(jwt: jwt, verbose: false).upload_file(ARGV[0])
data/lib/skynet/client.rb CHANGED
@@ -29,7 +29,8 @@ module Skynet
29
29
  # @option config [String] :portal url to a custom portal, defaults to https://siasky.net
30
30
  # @option config [String] :dirname Optional directory name on skynet
31
31
  # @option config [Boolean] :verbose Set to true to log network requests
32
-
32
+ # @option config [String] :jwt JWT token to upload files to a Skynet account
33
+ #
33
34
  def initialize(custom_config = {})
34
35
  @config = default_upload_options
35
36
  @config.merge!(custom_config)
@@ -193,6 +194,7 @@ module Skynet
193
194
  Typhoeus::Request.new(
194
195
  "#{portal}#{portal_path}",
195
196
  method: :post,
197
+ headers: default_headers,
196
198
  params: params,
197
199
  body: {
198
200
  file: f
@@ -209,7 +211,9 @@ module Skynet
209
211
  end
210
212
 
211
213
  def default_headers
212
- { "User-Agent": DEFAULT_USER_AGENT }
214
+ h = {}
215
+ h.merge!('Cookie' => "skynet-jwt=#{config[:jwt]}") if config[:jwt]
216
+ h
213
217
  end
214
218
 
215
219
  def format_response(res, custom_opts = {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Skynet
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skynet_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Klocker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -68,6 +68,7 @@ files:
68
68
  - LICENSE.txt
69
69
  - README.md
70
70
  - Rakefile
71
+ - bin/account_upload
71
72
  - bin/console
72
73
  - bin/setup
73
74
  - lib/skynet.rb