Skip to content

Commit

Permalink
awscloud: add new UploadFromReader()
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Jan 17, 2024
1 parent b81b603 commit e6de448
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/cloud/awscloud/awscloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/tls"
"encoding/base64"
"fmt"
"io"
"net/http"
"os"
"time"
Expand Down Expand Up @@ -139,13 +140,16 @@ func (a *AWS) Upload(filename, bucket, key string) (*s3manager.UploadOutput, err
logrus.Warnf("[AWS] ‼ Failed to close the file uploaded to S3️: %v", err)
}
}()
return a.UploadFromReader(file, bucket, key)
}

func (a *AWS) UploadFromReader(r io.Reader, bucket, key string) (*s3manager.UploadOutput, error) {
logrus.Infof("[AWS] 🚀 Uploading image to S3: %s/%s", bucket, key)
return a.uploader.Upload(
&s3manager.UploadInput{
Bucket: aws.String(bucket),
Key: aws.String(key),
Body: file,
Body: r,
},
)
}
Expand Down

0 comments on commit e6de448

Please sign in to comment.