SetRange - set the start and end offset of the object to be read. See https://tools.ietf.org/html/rfc7233#section-3.1 for reference.
(start, end int64)
| 160 | // SetRange - set the start and end offset of the object to be read. |
| 161 | // See https://tools.ietf.org/html/rfc7233#section-3.1 for reference. |
| 162 | func (o *GetObjectOptions) SetRange(start, end int64) error { |
| 163 | switch { |
| 164 | case start == 0 && end < 0: |
| 165 | // Read last '-end' bytes. `bytes=-N`. |
| 166 | o.Set("Range", fmt.Sprintf("bytes=%d", end)) |
| 167 | case 0 < start && end == 0: |
| 168 | // Read everything starting from offset |
| 169 | // 'start'. `bytes=N-`. |
| 170 | o.Set("Range", fmt.Sprintf("bytes=%d-", start)) |
| 171 | case 0 <= start && start <= end: |
| 172 | // Read everything starting at 'start' till the |
| 173 | // 'end'. `bytes=N-M` |
| 174 | o.Set("Range", fmt.Sprintf("bytes=%d-%d", start, end)) |
| 175 | default: |
| 176 | // All other cases such as |
| 177 | // bytes=-3- |
| 178 | // bytes=5-3 |
| 179 | // bytes=-2-4 |
| 180 | // bytes=-3-0 |
| 181 | // bytes=-3--2 |
| 182 | // are invalid. |
| 183 | return errInvalidArgument( |
| 184 | fmt.Sprintf( |
| 185 | "Invalid range specified: start=%d end=%d", |
| 186 | start, end)) |
| 187 | } |
| 188 | return nil |
| 189 | } |
| 190 | |
| 191 | // toQueryValues - Convert the versionId, partNumber, and reqParams in Options to query string parameters. |
| 192 | func (o *GetObjectOptions) toQueryValues() url.Values { |