Stat returns the ObjectInfo structure describing Object.
()
| 429 | |
| 430 | // Stat returns the ObjectInfo structure describing Object. |
| 431 | func (o *Object) Stat() (ObjectInfo, error) { |
| 432 | if o == nil { |
| 433 | return ObjectInfo{}, errInvalidArgument("Object is nil") |
| 434 | } |
| 435 | // Locking. |
| 436 | o.mutex.Lock() |
| 437 | defer o.mutex.Unlock() |
| 438 | |
| 439 | if o.prevErr != nil && o.prevErr != io.EOF || o.isClosed { |
| 440 | return ObjectInfo{}, o.prevErr |
| 441 | } |
| 442 | |
| 443 | // This is the first request. |
| 444 | if !o.isStarted || !o.objectInfoSet { |
| 445 | // Send the request and get the response. |
| 446 | _, err := o.doGetRequest(getRequest{ |
| 447 | isFirstReq: !o.isStarted, |
| 448 | settingObjectInfo: !o.objectInfoSet, |
| 449 | }) |
| 450 | if err != nil { |
| 451 | o.prevErr = err |
| 452 | return ObjectInfo{}, err |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | return o.objectInfo, nil |
| 457 | } |
| 458 | |
| 459 | // ReadAt reads len(b) bytes from the File starting at byte offset |
| 460 | // off. It returns the number of bytes read and the error, if any. |