File: object.go

package info (click to toggle)
golang-github-viant-toolbox 0.33.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,280 kB
  • sloc: makefile: 16
file content (34 lines) | stat: -rw-r--r-- 817 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package gs

import (
	"cloud.google.com/go/storage"
	"fmt"
	tstorage "github.com/viant/toolbox/storage"
	"os"
)

type object struct {
	*tstorage.AbstractObject
}

func (o *object) Unwrap(target interface{}) error {
	if fileInfo, casted := target.(**storage.ObjectAttrs); casted {
		source, ok := o.Source.(*storage.ObjectAttrs)
		if !ok {
			return fmt.Errorf("failed to case %T into %T", o.Source, target)
		}
		*fileInfo = source
		return nil
	}
	return fmt.Errorf("unsuported target %T", target)
}

//newObject creates a new gc storage object
func newStorageObject(url string, source interface{}, fileInfo os.FileInfo) tstorage.Object {
	abstract := tstorage.NewAbstractStorageObject(url, source, fileInfo)
	result := &object{
		AbstractObject: abstract,
	}
	result.AbstractObject.Object = result
	return result
}