github.com/viant/toolbox@v0.34.5/storage/README.md (about) 1 ## Storage API 2 3 Deprecated - please use https://github.com/viant/afs API instead 4 5 This API provides unified way of accessing any storage system. 6 7 It comes with the following implementation so far: 8 9 10 11 <a name="import></a> 12 13 14 | URL Scheme | Description | Pacakge | 15 |-----|-----|-----| 16 |file | Local file system | github.com/viant/toolbox/storage | 17 |https | HTTP/s based system | github.com/viant/toolbox/storage | 18 |mem | Memory file system | github.com/viant/toolbox/storage | 19 |scp | SCP/SSH base systm | github.com/viant/toolbox/storage/scp | 20 |s3 |Amazon Web Service S3| github.com/viant/toolbox/storage/aws | 21 |gs | Google Storage | github.com/viant/toolbox/storage/gs | 22 23 24 25 ```go 26 27 type Service interface { 28 //List returns a list of object for supplied url 29 List(URL string) ([]Object, error) 30 31 //Exists returns true if resource exists 32 Exists(URL string) (bool, error) 33 34 //Object returns a Object for supplied url 35 StorageObject(URL string) (Object, error) 36 37 //Download returns reader for downloaded storage object 38 Download(object Object) (io.ReadCloser, error) 39 40 //Upload uploads provided reader content for supplied storage object. 41 Upload(URL string, reader io.Reader) error 42 43 //Delete removes passed in storage object 44 Delete(object Object) error 45 46 //Register register schema with provided service 47 Register(schema string, service Service) error 48 49 //Closes storage service 50 Close() error 51 } 52 53 54 //Object represents a storage object 55 type Object interface { 56 //URL return storage url 57 URL() string 58 59 //Type returns storage type StorageObjectFolderType or StorageObjectContentType 60 Type() int 61 62 //IsFolder returns true if object is a folder 63 IsFolder() bool 64 65 //IsContent returns true if object is a file 66 IsContent() bool 67 68 //Wrap wraps source storage object 69 Wrap(source interface{}) 70 71 //Unwrap unwraps source storage object into provided target. 72 Unwrap(target interface{}) error 73 74 FileInfo() os.FileInfo 75 } 76 77 ``` 78 79 **Usage:** 80 81 82 ```go 83 import ( 84 "github.com/viant/toolbox/storage" 85 _ "github.com/viant/toolbox/storage/gs" 86 _ "github.com/viant/toolbox/storage/s3" 87 88 ) 89 90 destinationURL := "gs://myBucket/set1/content.gz" 91 destinationCredentialFile = "gs-secret.json" 92 storageService, err := storage.NewServiceForURL(destinationURL, destinationCredentialFile) 93 94 provider := storage.Registry().Get("s3") 95 storageS3Service, err := provider("aws-secret.json") 96 97 ```