MCPcopy
hub / github.com/NVIDIA/aistore / GetObjectWithValidation

Function GetObjectWithValidation

api/object.go:325–354  ·  view source on GitHub ↗

GetObjectWithValidation has same behavior as GetObject, but performs checksum validation of the object by comparing the checksum in the response header with the calculated checksum value derived from the returned object. Similar to GetObject, if a memory manager/slab allocator is not specified, a t

(baseParams BaseParams, bck cmn.Bck, object string, options ...GetObjectInput)

Source from the content-addressed store, hash-verified

323// Returns `cmn.ErrInvalidCksum` when the expected and actual checksum values
324// are different.
325func GetObjectWithValidation(baseParams BaseParams, bck cmn.Bck, object string, options ...GetObjectInput) (n int64, err error) {
326 var (
327 w = io.Discard
328 q url.Values
329 hdr http.Header
330 )
331 if len(options) != 0 {
332 w, q, hdr = getObjectOptParams(options[0])
333 }
334 baseParams.Method = http.MethodGet
335
336 reqParams := AllocRp()
337 {
338 reqParams.BaseParams = baseParams
339 reqParams.Path = apc.URLPathObjects.Join(bck.Name, object)
340 reqParams.Query = bck.AddToQuery(q)
341 reqParams.Header = hdr
342 reqParams.Validate = true
343 }
344 resp, err := reqParams.doResp(w)
345 FreeRp(reqParams)
346 if err != nil {
347 return 0, err
348 }
349 hdrCksumValue := resp.Header.Get(apc.HdrObjCksumVal)
350 if resp.cksumValue != hdrCksumValue {
351 return 0, cmn.NewErrInvalidCksum(hdrCksumValue, resp.cksumValue)
352 }
353 return resp.n, nil
354}
355
356// GetObjectWithResp returns the response and the length of the object.
357// It does not validate the checksum of the object in the response.

Callers 12

getObjectFunction · 0.92
testWarmValidationFunction · 0.92
getMethod · 0.92
TestObjectInvalidNameFunction · 0.92
TestRemoteBucketObjectFunction · 0.92
TestAppendObjectFunction · 0.92
verifyValidRangesFunction · 0.92
verifyInvalidRangesQueryFunction · 0.92

Calls 8

NewErrInvalidCksumFunction · 0.92
getObjectOptParamsFunction · 0.85
AllocRpFunction · 0.85
FreeRpFunction · 0.85
JoinMethod · 0.80
doRespMethod · 0.80
GetMethod · 0.65
AddToQueryMethod · 0.45