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
- Required
- Required
- Type
- context
- Description
- The context of the call, used for tracing. 
 
- Name
- key
- Required
- Required
- Type
- string
- Description
- The key of the file to write. 
 
- Name
- data
- Required
- Required
- 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 Feb 4, 2025