Fix Go AWS S3 example
* Fix Go AWS S3 example
Fixes
* Use path.Ext instead of manually figuring out extension
MODIFY
aws-go-s3-folder/main.go
aws-go-s3-folder/main.go
@@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"mime"
+ "path"
"path/filepath"
"github.com/pulumi/pulumi-aws/sdk/go/aws/s3"
@@ -34,10 +35,10 @@ func main() {
for _, item := range files {
name := item.Name()
filePath := filepath.Join(siteDir, name)
- if _, err := s3.NewBucketObject(ctx, filePath, &s3.BucketObjectArgs{
+ if _, err := s3.NewBucketObject(ctx, name, &s3.BucketObjectArgs{
Bucket: siteBucket.ID(), // reference to the s3.Bucket object
Source: asset.NewFileAsset(filePath), // use FileAsset to point to a file
- ContentType: mime.TypeByExtension(name), // set the MIME type of the file
+ ContentType: mime.TypeByExtension(path.Ext(name)), // set the MIME type of the file
}); err != nil {
return err
}
@@ -52,8 +53,8 @@ func main() {
}
// Stack exports
- ctx.Export("bucketName", siteBucket.ID)
- ctx.Export("websiteUrl", siteBucket.WebsiteEndpoint)
+ ctx.Export("bucketName", siteBucket.ID())
+ ctx.Export("websiteUrl", siteBucket.WebsiteEndpoint())
return nil
})
}

Fix Go AWS S3 example (#138)

* Fix Go AWS S3 example

Fixes #113

* Use path.Ext instead of manually figuring out extension