Go - Bucket.File.Write()
Write a file to a bucket.
import ("context""github.com/nitrictech/go-sdk/nitric""github.com/nitrictech/go-sdk/nitric/storage")func main() {bucket := nitric.NewBucket("bucket-name").Allow(storage.BucketWrite)err := bucket.Write(context.TODO(), "cat.png", []byte("contents"))if err != nil {return}nitric.Run()}
Parameters
- Name
ctx
- Type
- context
- Description
The context of the call, used for tracing.
- Name
key
- Type
- string
- Description
The key of the file to write.
- Name
data
- Type
- []byte
- Description
The data to write to the file.
Examples
Write a file
import ("context""github.com/nitrictech/go-sdk/nitric""github.com/nitrictech/go-sdk/nitric/storage")func main() {bucket := nitric.NewBucket("bucket-name").Allow(storage.BucketWrite)err := bucket.Write(context.TODO(), "cat.png", []byte("contents"))if err != nil {return}nitric.Run()}
Last updated on Oct 11, 2024