Go - Bucket.File.UploadUrl()
Create an upload URL for a file within 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.BucketWrite)uploadUrl, err := bucket.UploadUrl(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 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""github.com/nitrictech/go-sdk/nitric""github.com/nitrictech/go-sdk/nitric/storage")func main() {bucket := nitric.NewBucket("bucket-name").Allow(storage.BucketWrite)uploadUrl, err := bucket.UploadUrl(context.TODO(), "cat.png")if err != nil {return}nitric.Run()}
Last updated on Nov 4, 2024