atlas_rb 1.8.1 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/Gemfile.lock +1 -1
  4. data/lib/atlas_rb/blob.rb +25 -14
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de8129aceabcd06af713b7bddf2e4be8ff259bc3f8095af41d9e63cc2f03c17b
4
- data.tar.gz: 9a45c13597c30c4b0c09c9dfb0bf199edb7d919d050f10faaadc32cc2024af3b
3
+ metadata.gz: 0a0fac04427bc3f23f92da8a5241a263111f45b28fa01cc8829da0de3b6b48f9
4
+ data.tar.gz: 8e95150d0f2ecd0a33c52179e384f8462546b422dcd6997c69886163215811c8
5
5
  SHA512:
6
- metadata.gz: ee4d49599431a9052c3f3bc55d2d336bb967fedc61edb2815dda42cee74d2250b6700a51ea88c5b74a959fe2f562923e4486831bba66ceb7d5b0236fa74b054c
7
- data.tar.gz: 75e2208c86cc1d3e6e13a1bcde956d2d821a7e6e5a141004b2bc2743b550778bd621bcc70aed2528122fabcb931f60a2bc356ed99226a9ece39b125b4d3a3f09
6
+ metadata.gz: 4ced2b3f0f3fee473712f38ae3161ea8f678d9468abaf1250c9577e13261b5688be16ea687a69f6b28931a6e8920ad737d7a2057059c14751cceb683e463c2ef
7
+ data.tar.gz: 017e1004f59a5529184e3f07f93c815a463da07937863ff72b2063b3e1986f624e5e8ea83c0b5750b57885e7942ef981b32e66f7d3e5931ea6545108c643162d
data/.version CHANGED
@@ -1 +1 @@
1
- 1.8.1
1
+ 1.8.2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (1.8.1)
4
+ atlas_rb (1.8.2)
5
5
  faraday (~> 2.7)
6
6
  faraday-follow_redirects (~> 0.3.0)
7
7
  faraday-multipart (~> 1)
data/lib/atlas_rb/blob.rb CHANGED
@@ -86,10 +86,18 @@ module AtlasRb
86
86
  #
87
87
  # The body is **not** buffered — each chunk Faraday receives is yielded
88
88
  # to `chunk_handler` immediately, making this safe for files larger than
89
- # available memory. The first chunk's response headers are captured and
90
- # returned so callers can inspect `Content-Type`, `Content-Length`, etc.
89
+ # available memory.
90
+ #
91
+ # Pass `range:` (e.g. `"bytes=0-1048575"`) to forward an HTTP `Range`
92
+ # header; Atlas answers `206 Partial Content` and the chunks yielded are
93
+ # just the requested slice. The returned hash exposes both the response
94
+ # **status** (200 vs 206) and the response **headers** — so a caller
95
+ # proxying to a browser media element can relay `Content-Range`,
96
+ # `Content-Length` and `Accept-Ranges` verbatim and reproduce the 206.
91
97
  #
92
98
  # @param id [String] the Blob ID.
99
+ # @param range [String, nil] optional HTTP byte range (`"bytes=START-END"`,
100
+ # `"bytes=START-"`, or `"bytes=-SUFFIX"`). Omitted ⇒ whole-body `200`.
93
101
  # @param nuid [String, nil] optional acting user's NUID. On the relay-signing
94
102
  # path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
95
103
  # path it is ignored (identity lives in the token).
@@ -97,22 +105,25 @@ module AtlasRb
97
105
  # header. Falls through to {AtlasRb.config}.default_on_behalf_of when
98
106
  # omitted.
99
107
  # @yieldparam chunk [String] the next chunk of binary data.
100
- # @return [Hash] the response headers from `GET /files/<id>/content`.
108
+ # @return [Hash] `{ status: Integer, headers: Faraday::Utils::Headers }` for
109
+ # `GET /files/<id>/content` (`headers` is case-insensitive, hash-like).
101
110
  #
102
- # @example Stream to disk
111
+ # @example Stream the whole body to disk
103
112
  # File.open("/tmp/out.pdf", "wb") do |f|
104
- # headers = AtlasRb::Blob.content("b-321") { |chunk| f.write(chunk) }
105
- # puts headers["content-type"]
113
+ # res = AtlasRb::Blob.content("b-321") { |chunk| f.write(chunk) }
114
+ # puts res[:headers]["content-type"]
106
115
  # end
107
- def self.content(id, nuid: nil, on_behalf_of: nil, &chunk_handler)
108
- headers = {}
109
- connection({}, nuid, on_behalf_of: on_behalf_of).get("#{ROUTE}#{id}/content") do |req|
110
- req.options.on_data = proc do |chunk, _bytes_received, env|
111
- headers = env.response_headers if headers.empty? && env
112
- chunk_handler.call(chunk)
113
- end
116
+ #
117
+ # @example Relay a browser's Range request as a 206
118
+ # res = AtlasRb::Blob.content("b-321", range: "bytes=0-1048575") { |c| out << c }
119
+ # res[:status] # => 206
120
+ # res[:headers]["content-range"] # => "bytes 0-1048575/52428800"
121
+ def self.content(id, range: nil, nuid: nil, on_behalf_of: nil, &chunk_handler)
122
+ response = connection({}, nuid, on_behalf_of: on_behalf_of).get("#{ROUTE}#{id}/content") do |req|
123
+ req.headers["Range"] = range if range
124
+ req.options.on_data = proc { |chunk, _bytes_received, _env| chunk_handler.call(chunk) }
114
125
  end
115
- headers
126
+ { status: response.status, headers: response.headers }
116
127
  end
117
128
 
118
129
  # Upload a new Blob attached to a Work.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlas_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cliff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-25 00:00:00.000000000 Z
11
+ date: 2026-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday