diff --git a/aws_s3.go b/aws_s3.go index d028765..5684bd2 100644 --- a/aws_s3.go +++ b/aws_s3.go @@ -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()