Go is in development for v1. Interested in contributing or chatting with us?Get in touch!
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").With(nitric.BucketWriting)
if err != nil {
return
}
uploadUrl, err := bucket.File("cat.png").UploadUrl(context.TODO(), 600)
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
expiry
- Required
- Required
- Type
- int
- Description
Seconds until link expiry. Maximum of
604800
(7 days).
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").With(nitric.BucketWriting)
if err != nil {
return
}
uploadUrl, err := bucket.File("cat.png").UploadUrl(context.TODO(), 600)
if err != nil {
return
}
if err := nitric.Run(); err != nil {
fmt.Println(err)
}
}