You've already forked email-api-client
refactor: optimize file content encoding in NewAttachmentFromFileContent
All checks were successful
🚀 Publish Release Package / publish (push) Successful in 21s
All checks were successful
🚀 Publish Release Package / publish (push) Successful in 21s
This commit is contained in:
@@ -7,11 +7,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewAttachmentFromFileContent(fileName string, f []byte) (*FileAttachment, error) {
|
func NewAttachmentFromFileContent(fileName string, f []byte) (*FileAttachment, error) {
|
||||||
base64.StdEncoding.Encode(f, f)
|
buffer := make([]byte, base64.StdEncoding.EncodedLen(len(f)))
|
||||||
|
base64.StdEncoding.Encode(buffer, f)
|
||||||
|
|
||||||
return &FileAttachment{
|
return &FileAttachment{
|
||||||
Filename: fileName,
|
Filename: fileName,
|
||||||
Content: string(f),
|
Content: string(buffer),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user