added reference to the file provider interface

This commit is contained in:
Ethan Holz
2023-10-30 17:50:16 -05:00
parent 3fae920e66
commit ca694fecd5

View File

@@ -2,7 +2,17 @@
title: grlx.ingedients.file.providers
description: grlx built-in file providers
---
`grlx` has a concept of file providers for different ways that you might obtain a file to be added to a given `sprout`. This uses a provider interface to keep this extensible and provide a standard way to use different file types. By default, `grlx` has three built-in providers: local, HTTP, and S3.
`grlx` has a concept of file providers for different ways that you might obtain a file to be added to a given `sprout`. This uses a provider interface to keep this extensible and provide a standard way to use different file types. The `go` interface for File Providers looks like the following:
```go
type FileProvider interface {
Download(context.Context) error
Properties() (map[string]interface{}, error)
Parse(id, source, destination, hash string, properties map[string]interface{}) (FileProvider, error)
Protocols() []string
Verify(context.Context) (bool, error)
}
```
By default, `grlx` has three built-in providers: local, HTTP, and S3.
## Local
The local provider would be how you would use a file from your host system.
@@ -14,7 +24,7 @@ file.cached:
```
## HTTP
The HTTP provider allows you to download files via HTTP for use. The [example](/ingredients/file-providers/#example) below is using the HTTP provider to download Go from the Internet. This file then gets cached to the sprout.
The HTTP provider allows you to download files via HTTP for use. The [example](/ingredients/file-providers/#example) below is using the HTTP provider to download Go from the Internet. This file then gets cached to the sprout.
#### Example
```yaml
file.cached: