The Go SDK is currently in experimental status. If you would like to provide feedback, please reach out to us with your suggestions and comments on our Discord.
Go - Bucket.File.UploadUrl()
Create an upload URL for a file within a bucket.
import (
"context"
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
bucket, err := nitric.NewBucket("bucket-name").Allow(nitric.BucketWrite)
if err != nil {
return
}
uploadUrl, err := bucket.UploadUrl(context.TODO(), "cat.png")
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.
- Name
key
- Required
- Required
- Type
- string
- Description
The key of the file to create an upload url for.
- Name
...opts
- Required
- Required
- Type
- storage.PresignUrlOption
- Description
Options to configure the upload url.
Examples
Create a temporary file upload link for a user
import (
"context"
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
bucket, err := nitric.NewBucket("bucket-name").Allow(nitric.BucketWrite)
if err != nil {
return
}
uploadUrl, err := bucket.UploadUrl(context.TODO(), "cat.png")
if err != nil {
return
}
if err := nitric.Run(); err != nil {
fmt.Println(err)
}
}