Go - Bucket.File.Delete()

Delete a file from 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.BucketDelete)
err := bucket.Delete(context.TODO(), "cat.png")
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 delete.

Examples

Delete 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.BucketDelete)
err := bucket.Delete(context.TODO(), "cat.png")
if err != nil {
return
}
nitric.Run()
}
Last updated on Nov 8, 2024