File tree Expand file tree Collapse file tree 4 files changed +27
-6
lines changed Expand file tree Collapse file tree 4 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,24 @@ export class GeneralHelper {
232
232
}
233
233
}
234
234
235
+ /**
236
+ * To support IE11 that has no support for File constructor
237
+ * @param blob
238
+ */
239
+ public static getFileFromBlob ( blob :Blob , fileName : string ) : File {
240
+ let result : any = null ;
241
+ // IE 11 foesn't support File API, create a workaround to return Blob with fileName assigned.
242
+ try {
243
+ result = new File ( [ blob ] , fileName ) ;
244
+ }
245
+ catch ( ieErr ) {
246
+ result = blob ;
247
+ result . fileName = fileName ;
248
+ }
249
+
250
+ return result ;
251
+ }
252
+
235
253
public static formatBytes ( bytes , decimals ) {
236
254
if ( bytes == 0 ) {
237
255
return strings . EmptyFileSize ;
Original file line number Diff line number Diff line change @@ -92,8 +92,8 @@ export class FileBrowserService {
92
92
}
93
93
94
94
// Return file created from blob
95
- const blob : Blob = await fileDownloadResult . blob ( ) ;
96
- return new File ( [ blob ] , fileName ) ;
95
+ const blob : Blob = await fileDownloadResult . blob ( ) ;
96
+ return GeneralHelper . getFileFromBlob ( blob , fileName ) ;
97
97
} catch ( err ) {
98
98
console . error ( `[FileBrowserService.fetchFileContent] Err='${ err . message } '` ) ;
99
99
return null ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { SPHttpClient } from "@microsoft/sp-http";
3
3
import { ISearchResult , BingQuerySearchParams , IRecentFile } from "./FilesSearchService.types" ;
4
4
import { find } from "office-ui-fabric-react/lib/Utilities" ;
5
5
import { ExtensionContext } from "@microsoft/sp-extension-base" ;
6
+ import { GeneralHelper } from "../common/utilities" ;
6
7
7
8
/**
8
9
* Maximum file size when searching
@@ -181,7 +182,8 @@ export class FilesSearchService {
181
182
182
183
// Return file created from blob
183
184
const blob : Blob = await fileDownloadResult . blob ( ) ;
184
- return new File ( [ blob ] , fileName ) ;
185
+ // Retrieve file from blob - method supports IE11
186
+ return GeneralHelper . getFileFromBlob ( blob , fileName ) ;
185
187
} catch ( err ) {
186
188
console . error ( `[FileSearchService.fetchFileContent] Err='${ err . message } '` ) ;
187
189
return null ;
@@ -204,7 +206,7 @@ export class FilesSearchService {
204
206
205
207
// Return file created from blob
206
208
const blob : Blob = await fileDownloadResult . blob ( ) ;
207
- return new File ( [ blob ] , fileName ) ;
209
+ return GeneralHelper . getFileFromBlob ( blob , fileName ) ;
208
210
} catch ( err ) {
209
211
console . error ( `[FileSearchService.fetchFileContent] Err='${ err . message } '` ) ;
210
212
return null ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { SPHttpClient } from '@microsoft/sp-http';
5
5
import { FileBrowserService } from "./FileBrowserService" ;
6
6
import { FilesQueryResult } from "./FileBrowserService.types" ;
7
7
import { ExtensionContext } from "@microsoft/sp-extension-base" ;
8
+ import { GeneralHelper } from "../Utilities" ;
8
9
9
10
export class OneDriveService extends FileBrowserService {
10
11
protected oneDrivePersonalUrl : string ;
@@ -77,8 +78,8 @@ export class OneDriveService extends FileBrowserService {
77
78
}
78
79
79
80
// Return file created from blob
80
- const blob : Blob = await fileDownloadResult . blob ( ) ;
81
- return new File ( [ blob ] , fileName ) ;
81
+ const blob : Blob = await fileDownloadResult . blob ( ) ;
82
+ return GeneralHelper . getFileFromBlob ( blob , fileName ) ;
82
83
} catch ( err ) {
83
84
console . error ( `[OneDriveService.fetchFileContent] Err='${ err . message } '` ) ;
84
85
return null ;
You can’t perform that action at this time.
0 commit comments