Skip to content

Commit 4d47070

Browse files
committed
download endpoint documentation
1 parent 0d260a8 commit 4d47070

File tree

8 files changed

+455
-47
lines changed

8 files changed

+455
-47
lines changed

code/go/0chain.net/blobbercore/filestore/store.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func GetFileStore() FileStorer {
8787
return fileStore
8888
}
8989

90+
// swagger:model FileDownloadResponse
9091
type FileDownloadResponse struct {
9192
Nodes [][][]byte
9293
Indexes [][]int

code/go/0chain.net/blobbercore/handler/handler_main.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -23,53 +23,6 @@ func SetupHandlers(r *mux.Router) {
2323
}
2424

2525

26-
// swagger:route GET /v1/file/list/{allocation} list
27-
// ListHandler is the handler to respond to list requests from clients,
28-
// it returns a list of files in the allocation,
29-
// along with the metadata of the files.
30-
//
31-
// parameters:
32-
//
33-
// +name: allocation
34-
// description: TxHash of the allocation in question.
35-
// in: path
36-
// required: true
37-
// type: string
38-
// +name: list
39-
// description: Whether or not to list the files inside the directory, not just data about the path itself.
40-
// in: query
41-
// type: boolean
42-
// required: false
43-
// +name: limit
44-
// description: The number of files to return (for pagination).
45-
// in: query
46-
// type: integer
47-
// required: true
48-
// +name: offset
49-
// description: The number of files to skip before returning (for pagination).
50-
// in: query
51-
// type: integer
52-
// required: true
53-
// +name: X-App-Client-ID
54-
// description: The ID/Wallet address of the client sending the request.
55-
// in: header
56-
// type: string
57-
// required: true
58-
// +name: X-App-Client-Key
59-
// description: The key of the client sending the request.
60-
// in: header
61-
// type: string
62-
// required: true
63-
// +name: ALLOCATION-ID
64-
// description: The ID of the allocation in question.
65-
// in: header
66-
// type: string
67-
// required: true
68-
//
69-
// responses:
70-
//
71-
// 200: ListResult
72-
7326
func ListHandler(ctx context.Context, r *http.Request) (interface{}, error) {
7427
return listHandler(ctx, r)
7528
}

code/go/0chain.net/blobbercore/handler/object_operation_handler.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,95 @@ func (fsh *StorageHandler) RedeemReadMarker(ctx context.Context, r *http.Request
263263
}, nil
264264
}
265265

266+
// swagger:route POST /v1/file/download/{allocation} downloadFile
267+
//
268+
// DownloadHandler is the handler to respond to download requests from clients.
269+
//
270+
// parameters:
271+
// +name: allocation
272+
// description: TxHash of the allocation in question.
273+
// in: path
274+
// required: true
275+
// type: string
276+
// +name: X-App-Client-ID
277+
// description: The ID/Wallet address of the client sending the request.
278+
// in: header
279+
// type: string
280+
// required: true
281+
// +name: X-App-Client-Key
282+
// description: The key of the client sending the request.
283+
// in: header
284+
// type: string
285+
// required: true
286+
// +name: ALLOCATION-ID
287+
// description: The ID of the allocation in question.
288+
// in: header
289+
// type: string
290+
// required: true
291+
// +name: X-Connection-ID
292+
// description: The ID of the connection used for the download. Usually, the download process occurs in multiple requests, on per block, where all of them are done in a single connection between the client and the blobber.
293+
// in: header
294+
// type: string
295+
// required: false
296+
// +name: X-Path-Hash
297+
// description: The hash of the path of the file to download. If not provided, will be calculated from "X-Path" parameter.
298+
// in: header
299+
// type: string
300+
// required: false
301+
// +name: X-Path
302+
// description: The path of the file to download.
303+
// in: header
304+
// type: string
305+
// required: true
306+
// +name: X-Block-Num
307+
// description: The block number of the file to download. Must be 0 or greater (valid index).
308+
// in: header
309+
// type: integer
310+
// required: false
311+
// default: 0
312+
// +name: X-Num-Blocks
313+
// description: The number of blocks to download. Must be 0 or greater.
314+
// in: header
315+
// type: integer
316+
// required: false
317+
// default: 0
318+
// +name: X-Read-Marker
319+
// description: The read marker to use for the download (check [ReadMarker](#/responses/ReadMarker)).
320+
// in: header
321+
// type: string
322+
// required: false
323+
// +name: X-Auth-Token
324+
// description: The auth token to use for the download. If the file is shared, the auth token is required.
325+
// in: header
326+
// type: string
327+
// +name: X-Mode
328+
// description: Download mode. Either "full" for full file download, or "thumbnail" to download the thumbnail of the file
329+
// in: header
330+
// type: string
331+
// +name: X-Verify-Download
332+
// description: If set to "true", the download should be verified. If the mode is "thumbnail",
333+
// the thumbnail hash stored in the db is compared with the hash of the actual file.
334+
// If the mode is "full", merkle proof is calculated and returned in the response.
335+
// in: header
336+
// type: string
337+
// +name: X-Version
338+
// description: If its value is "v2" then both allocation_id and blobber url base are hashed and verified using X-App-Client-Signature-V2.
339+
// in: header
340+
// type: string
341+
// +name: X-App-Client-Signature
342+
// description: Digital signature of the client used to verify the request if the X-Version is not "v2"
343+
// in: header
344+
// type: string
345+
// +name: X-App-Client-Signature-V2
346+
// description: Digital signature of the client used to verify the request if the X-Version is "v2"
347+
// in: header
348+
// type: string
349+
//
350+
// responses:
351+
//
352+
// 200: FileDownloadResponse | []byte
353+
// 400:
354+
266355
func (fsh *StorageHandler) DownloadFile(ctx context.Context, r *http.Request) (interface{}, error) {
267356
// get client and allocation ids
268357

code/go/0chain.net/blobbercore/handler/storage_handler.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,69 @@ func (fsh *StorageHandler) GetFileStats(ctx context.Context, r *http.Request) (i
274274
return result, nil
275275
}
276276

277+
// swagger:route GET /v1/file/list/{allocation} list
278+
// ListHandler is the handler to respond to list requests from clients,
279+
// it returns a list of files in the allocation,
280+
// along with the metadata of the files.
281+
//
282+
// parameters:
283+
//
284+
// +name: allocation
285+
// description: TxHash of the allocation in question.
286+
// in: path
287+
// required: true
288+
// type: string
289+
// +name:path
290+
// description: The path needed to list info about
291+
// in: query
292+
// type: string
293+
// required: true
294+
// +name: path_hash
295+
// description: Lookuphash of the path needed to list info about, which is a hex hash of the path concatenated with the allocation ID.
296+
// in: query
297+
// type: string
298+
// required: false
299+
// +name: auth_token
300+
// description: The auth ticket for the file to download if the client does not own it. Check File Sharing docs for more info.
301+
// in: query
302+
// type: string
303+
// required: false
304+
// +name: list
305+
// description: Whether or not to list the files inside the directory, not just data about the path itself.
306+
// in: query
307+
// type: boolean
308+
// required: false
309+
// +name: limit
310+
// description: The number of files to return (for pagination).
311+
// in: query
312+
// type: integer
313+
// required: true
314+
// +name: offset
315+
// description: The number of files to skip before returning (for pagination).
316+
// in: query
317+
// type: integer
318+
// required: true
319+
// +name: X-App-Client-ID
320+
// description: The ID/Wallet address of the client sending the request.
321+
// in: header
322+
// type: string
323+
// required: true
324+
// +name: X-App-Client-Key
325+
// description: The key of the client sending the request.
326+
// in: header
327+
// type: string
328+
// required: true
329+
// +name: ALLOCATION-ID
330+
// description: The ID of the allocation in question.
331+
// in: header
332+
// type: string
333+
// required: true
334+
//
335+
// responses:
336+
//
337+
// 200: ListResult
338+
// 400:
339+
277340
func (fsh *StorageHandler) ListEntities(ctx context.Context, r *http.Request) (*blobberhttp.ListResult, error) {
278341
clientID := ctx.Value(constants.ContextKeyClient).(string)
279342
allocationId := ctx.Value(constants.ContextKeyAllocationID).(string)

code/go/0chain.net/blobbercore/readmarker/authticket.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const (
1313
NinetyDays = common.Timestamp(90 * 24 * time.Hour)
1414
)
1515

16+
// swagger:model AuthTicke
1617
type AuthTicket struct {
1718
ClientID string `json:"client_id"`
1819
OwnerID string `json:"owner_id"`

code/go/0chain.net/blobbercore/readmarker/readmarker.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
// Only when blobber is not in sync with blockchain, SaveLatestReadMarker will be called.
2828
var ReadmarkerMapLock = common.GetNewLocker()
2929

30+
// swagger:model ReadMarker
3031
type ReadMarker struct {
3132
ClientID string `gorm:"column:client_id;size:64;primaryKey" json:"client_id"`
3233
AllocationID string `gorm:"column:allocation_id;size:64;primaryKey" json:"allocation_id"`

0 commit comments

Comments
 (0)