File tree 1 file changed +13
-1
lines changed
src/main/java/org/simplejavamail/converter/internal/mimemessage
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 1
1
package org .simplejavamail .converter .internal .mimemessage ;
2
2
3
3
import javax .activation .DataSource ;
4
+ import javax .mail .EncodingAware ;
4
5
import java .io .IOException ;
5
6
import java .io .InputStream ;
6
7
import java .io .OutputStream ;
10
11
/**
11
12
* Allows given datasource to be renamed (from {@link javax.activation.DataHandler} perspective).
12
13
*/
13
- class NamedDataSource implements DataSource {
14
+ class NamedDataSource implements DataSource , EncodingAware {
14
15
15
16
/**
16
17
* Original data source used for attachment.
@@ -69,4 +70,15 @@ public String getContentType() {
69
70
public String getName () {
70
71
return !valueNullOrEmpty (name ) ? name : dataSource .getName ();
71
72
}
73
+
74
+ /**
75
+ * Optimization to help Java Mail determine encoding for attachments.
76
+ *
77
+ * @return The encoding from the nested data source if it implements {@link EncodingAware} as well.
78
+ * @see <a href="https://github.com/bbottema/simple-java-mail/issues/131">Bug report #131</a>
79
+ */
80
+ @ Override
81
+ public String getEncoding () {
82
+ return (this .dataSource instanceof EncodingAware ) ? ((EncodingAware ) this .dataSource ).getEncoding () : null ;
83
+ }
72
84
}
You can’t perform that action at this time.
0 commit comments