github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/api/s3.go (about) 1 // Package api provides native Go-based API/SDK over HTTP(S). 2 /* 3 * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. 4 */ 5 package api 6 7 import ( 8 "io" 9 "net/http" 10 "net/url" 11 12 "github.com/NVIDIA/aistore/api/apc" 13 "github.com/NVIDIA/aistore/cmn" 14 ) 15 16 // s3/<bucket-name>/<object-name> 17 func GetObjectS3(bp BaseParams, bck cmn.Bck, objectName string, args ...GetArgs) (int64, error) { 18 var ( 19 q url.Values 20 hdr http.Header 21 w = io.Discard 22 ) 23 if len(args) != 0 { 24 w, q, hdr = args[0].ret() 25 } 26 q = bck.AddToQuery(q) 27 bp.Method = http.MethodGet 28 reqParams := AllocRp() 29 { 30 reqParams.BaseParams = bp 31 reqParams.Path = apc.URLPathS3.Join(bck.Name, objectName) 32 reqParams.Query = q 33 reqParams.Header = hdr 34 } 35 wresp, err := reqParams.doWriter(w) 36 FreeRp(reqParams) 37 if err != nil { 38 return 0, err 39 } 40 return wresp.n, nil 41 }