Skip to content

Commit

Permalink
openapi: add GET /object/*key
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Dec 9, 2024
1 parent 701a6f5 commit ad621be
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 22 deletions.
81 changes: 80 additions & 1 deletion openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ paths:
ETag:
description: The ETag of the uploaded part
schema:
- $ref: "#/components/schemas/ETag"
$ref: "#/components/schemas/ETag"
"400":
description: Invalid combination of request parameters
content:
Expand All @@ -349,6 +349,85 @@ paths:
text/plain:
schema:
type: string
/worker/object/{key}:
get:
summary: Download an object
description: Downloads an object from the Sia network.
parameters:
- name: key
description: The key of the file to download
in: path
required: true
schema:
type: string
example: "myDir/myFile"
minLength: 1
- name: bucket
description: The bucket the object belongs to
example: "myBucket"
in: query
required: true
schema:
$ref: "#/components/schemas/Bucket"
- name: Range
in: header
description: The range of bytes to download. If not provided, the entire object will be downloaded.
schema:
type: string
example: "bytes=0-100"
responses:
"200":
description: Successfully downloaded object
content:
application/octet-stream:
schema:
type: string
format: binary
headers:
"Accept-Ranges":
description: The range units the server supports
schema:
type: string
"Content-Range":
description: The range of bytes that were downloaded
schema:
type: string
"Content-Type":
description: The content type of the object
schema:
type: string
"ETag":
description: The ETag of the downloaded object
schema:
$ref: "#/components/schemas/ETag"
"400":
description: Invalid range or missing parameters
content:
text/plain:
schema:
type: string
example: invalid range
"404":
description: Object not found
content:
text/plain:
schema:
type: string
example: object not found
"416":
description: No overlap between 'Range' and object's content
content:
text/plain:
schema:
type: string
example: "invalid range: failed to overlap"
"500":
description: Internal server error
content:
text/plain:
schema:
type: string
example: "failed to fetch object metadata"

components:
schemas:
Expand Down
21 changes: 0 additions & 21 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,27 +385,6 @@ func (w *Worker) objectHandlerGET(jc jape.Context) {
return
}

var prefix string
if jc.DecodeForm("prefix", &prefix) != nil {
return
}
var sortBy string
if jc.DecodeForm("sortby", &sortBy) != nil {
return
}
var sortDir string
if jc.DecodeForm("sortdir", &sortDir) != nil {
return
}
var marker string
if jc.DecodeForm("marker", &marker) != nil {
return
}
var ignoreDelim bool
if jc.DecodeForm("ignoredelim", &ignoreDelim) != nil {
return
}

key := jc.PathParam("key")
if key == "" {
jc.Error(errors.New("no path provided"), http.StatusBadRequest)
Expand Down

0 comments on commit ad621be

Please sign in to comment.