@@ -67,6 +67,22 @@ export class Upload extends EventEmitter {
6767 */
6868 private overrideFileName ;
6969
70+ /**
71+ * Mimetype of the file
72+ *
73+ * @private
74+ * @memberof Upload
75+ */
76+ private mimetype ;
77+
78+ /**
79+ * Alt Text of the file
80+ *
81+ * @private
82+ * @memberof Upload
83+ */
84+ private altText ;
85+
7086 private lastProgress : ProgressEvent = {
7187 totalBytes : 0 ,
7288 totalPercent : 0 ,
@@ -102,6 +118,16 @@ export class Upload extends EventEmitter {
102118 delete this . storeOptions . sanitizer ;
103119 }
104120
121+ if ( storeOptions . altText ) {
122+ this . altText = storeOptions . altText ;
123+ delete this . storeOptions . altText ;
124+ }
125+
126+ if ( storeOptions . mimetype ) {
127+ this . mimetype = storeOptions . mimetype ;
128+ delete this . storeOptions . mimetype ;
129+ }
130+
105131 this . uploader = new S3Uploader ( this . storeOptions , options . concurrency ) ;
106132
107133 this . uploader . setRetryConfig ( {
@@ -199,16 +225,16 @@ export class Upload extends EventEmitter {
199225 * Upload single file
200226 *
201227 * @param {(InputFile) } file
202- * @param {(string) } altText
203228 * @returns {Promise<any> }
204229 * @memberof Upload
205230 */
206- async upload ( input : InputFile , altText ?: string ) : Promise < any > {
231+ async upload ( input : InputFile ) : Promise < any > {
207232
208- const f = await getFile ( input , this . sanitizerOptions ) ;
233+ const f = await getFile ( input , this . sanitizerOptions , this . mimetype ) ;
209234 f . customName = this . overrideFileName ;
210- if ( altText ) {
211- f . alt = altText ;
235+
236+ if ( this . overrideFileName ) {
237+ f . alt = this . altText
212238 }
213239
214240 this . uploader . addFile ( f ) ;
@@ -240,8 +266,13 @@ export class Upload extends EventEmitter {
240266 continue ;
241267 }
242268
243- const f = await getFile ( input [ i ] , this . sanitizerOptions ) ;
269+ const f = await getFile ( input [ i ] , this . sanitizerOptions , this . mimetype ) ;
244270 f . customName = this . overrideFileName ;
271+
272+ if ( this . overrideFileName ) {
273+ f . alt = this . altText
274+ }
275+
245276 this . uploader . addFile ( f ) ;
246277 }
247278
0 commit comments