github.com/viant/toolbox@v0.34.5/storage/gs/object.go (about) 1 package gs 2 3 import ( 4 "cloud.google.com/go/storage" 5 "fmt" 6 tstorage "github.com/viant/toolbox/storage" 7 "os" 8 ) 9 10 type object struct { 11 *tstorage.AbstractObject 12 } 13 14 func (o *object) Unwrap(target interface{}) error { 15 if fileInfo, casted := target.(**storage.ObjectAttrs); casted { 16 source, ok := o.Source.(*storage.ObjectAttrs) 17 if !ok { 18 return fmt.Errorf("failed to case %T into %T", o.Source, target) 19 } 20 *fileInfo = source 21 return nil 22 } 23 return fmt.Errorf("unsuported target %T", target) 24 } 25 26 //newObject creates a new gc storage object 27 func newStorageObject(url string, source interface{}, fileInfo os.FileInfo) tstorage.Object { 28 abstract := tstorage.NewAbstractStorageObject(url, source, fileInfo) 29 result := &object{ 30 AbstractObject: abstract, 31 } 32 result.AbstractObject.Object = result 33 return result 34 }