Skip to content

Commit

Permalink
Novo método: UpdloadInS3NotTime
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-couto committed Mar 29, 2022
1 parent cec7d58 commit 2fe3f02
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions aws_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,36 @@ func UpdloadInS3(file multipart.File, path, fileName string) string {
return "https://" + myBucket + "." + "s3.amazonaws.com/" + fileName
}

func UpdloadInS3NotTime(file multipart.File, path, fileName string) string {
// The session the S3 Uploader will use
sess := ConnectAws()

// Caso tenha om PATH ai ele concatena
if path != "" {
fileName = fmt.Sprint(path, "/", fileName)
}

// Create an uploader with the session and default options
uploader := s3manager.NewUploader(sess)

myBucket := Godotenv("BUCKET_NAME")

//file, header, err := c.Request.FormFile("photo")
//upload to the s3 bucket
up, err := uploader.Upload(&s3manager.UploadInput{
Bucket: aws.String(myBucket),
ACL: aws.String("public-read"),
Key: aws.String(fileName),
Body: file,
})
if err != nil {
CreateFileDay(Message{Error: err.Error()})
return ""
}
CreateFileDay(Message{Info: fmt.Sprint("Upload do Arquivo: ", up.UploadID)})
return "https://" + myBucket + "." + "s3.amazonaws.com/" + fileName
}

func UpdloadInS3Base64(b64 string, path, fileName string) string {
// The session the S3 Uploader will use
sess := ConnectAws()
Expand Down

0 comments on commit 2fe3f02

Please sign in to comment.