Go - Bucket.File.Delete()

Delete a file from a bucket.

import (
  "context"
  "fmt"

  "github.com/nitrictech/go-sdk/nitric"
)

func main() {
  bucket, err := nitric.NewBucket("bucket-name").Allow(nitric.BucketDelete)
  if err != nil {
    return
  }

  err = bucket.File("cat.png").Delete(context.TODO())
  if err != nil {
    return
  }

  if err := nitric.Run(); err != nil {
    fmt.Println(err)
  }
}

Parameters

  • Name
    ctx
    Required
    Required
    Type
    context
    Description

    The context of the call, used for tracing.

Examples

Delete a file

import (
  "context"
  "fmt"

  "github.com/nitrictech/go-sdk/nitric"
)

func main() {
  bucket, err := nitric.NewBucket("bucket-name").Allow(nitric.BucketDelete)
  if err != nil {
    return
  }

  err = bucket.File("cat.png").Delete(context.TODO())
  if err != nil {
    return
  }

  if err := nitric.Run(); err != nil {
    fmt.Println(err)
  }
}