Add comments and clean up code
This commit is contained in:
parent
364c664211
commit
198349f683
@ -46,9 +46,10 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an Amazon S3 service client
|
|
||||||
client := s3.NewFromConfig(cfg)
|
client := s3.NewFromConfig(cfg)
|
||||||
|
|
||||||
|
// The whole contents of the public/ directory are uploaded. This code assumes
|
||||||
|
// the directory structure is flat - there are no subdirectories.
|
||||||
publicDir := "./public/"
|
publicDir := "./public/"
|
||||||
c, err := os.ReadDir(publicDir)
|
c, err := os.ReadDir(publicDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -66,14 +67,14 @@ func main() {
|
|||||||
contentType := guessContentType(entry.Name())
|
contentType := guessContentType(entry.Name())
|
||||||
log.Printf("Uploading %s (%s)", entry.Name(), contentType)
|
log.Printf("Uploading %s (%s)", entry.Name(), contentType)
|
||||||
|
|
||||||
input := &s3.PutObjectInput{
|
cfg := &s3.PutObjectInput{
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
Key: aws.String(entry.Name()),
|
Key: aws.String(entry.Name()),
|
||||||
Body: file,
|
Body: file,
|
||||||
ContentType: aws.String(contentType),
|
ContentType: aws.String(contentType),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = client.PutObject(context.TODO(), input)
|
_, err = client.PutObject(context.TODO(), cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user