Go - Bucket.File.Write()

Write a file to a bucket.

import (
"context"
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
bucket, err := nitric.NewBucket("bucket-name").With(nitric.BucketWriting)
if err != nil {
return
}
err := bucket.File("cat.png").Write(context.TODO(), []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
    data
    Required
    Required
    Type
    []byte
    Description

    The data to write to the file.

Examples

Write a file

import (
"context"
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
bucket, err := nitric.NewBucket("bucket-name").With(nitric.BucketWriting)
if err != nil {
return
}
err := bucket.File("cat.png").Write(context.TODO(), []byte("contents"))
if err != nil {
return
}
nitric.Run()
}
Last updated on Oct 11, 2024