Skip to content

Commit

Permalink
fix attachments always empty, by reading input stream only once
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenMassaro committed Apr 1, 2024
1 parent 17ef2c1 commit bd19a1e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.massaro</groupId>
<artifactId>Email</artifactId>
<version>2.9.7</version>
<version>2.9.8</version>

<parent>
<groupId>org.springframework.boot</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/email/model/Attachment.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static Attachment fromDataSource(DataSource dataSource) throws IOExceptio
String contentType = dataSource.getContentType();
byte[] file = IOUtils.toByteArray(dataSource.getInputStream());
if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(contentType) && file != null) {
return new Attachment(dataSource.getName(), dataSource.getContentType(), IOUtils.toByteArray(dataSource.getInputStream()));
return new Attachment(dataSource.getName(), dataSource.getContentType(), file);
}
return null;
}
Expand Down

0 comments on commit bd19a1e

Please sign in to comment.