Merge pull request #1768 from dpalou/MOBILE-2869
MOBILE-2869 core: Support '*' as accepted file typesmain
commit
a1271ac2c0
|
@ -77,7 +77,9 @@ export class CoreAttachmentsComponent implements OnInit {
|
||||||
this.maxSubmissionsReadable = String(this.maxSubmissions);
|
this.maxSubmissionsReadable = String(this.maxSubmissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.acceptedTypes && this.acceptedTypes.trim()) {
|
this.acceptedTypes = this.acceptedTypes && this.acceptedTypes.trim();
|
||||||
|
|
||||||
|
if (this.acceptedTypes && this.acceptedTypes != '*') {
|
||||||
this.fileTypes = this.fileUploaderProvider.prepareFiletypeList(this.acceptedTypes);
|
this.fileTypes = this.fileUploaderProvider.prepareFiletypeList(this.acceptedTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,9 +333,16 @@ export class CoreFileUploaderProvider {
|
||||||
* Parse filetypeList to get the list of allowed mimetypes and the data to render information.
|
* Parse filetypeList to get the list of allowed mimetypes and the data to render information.
|
||||||
*
|
*
|
||||||
* @param {string} filetypeList Formatted string list where the mimetypes can be checked.
|
* @param {string} filetypeList Formatted string list where the mimetypes can be checked.
|
||||||
* @return {{info: any[], mimetypes: string[]}} Mimetypes and the filetypes informations.
|
* @return {{info: any[], mimetypes: string[]}} Mimetypes and the filetypes informations. Undefined if all types supported.
|
||||||
*/
|
*/
|
||||||
prepareFiletypeList(filetypeList: string): { info: any[], mimetypes: string[] } {
|
prepareFiletypeList(filetypeList: string): { info: any[], mimetypes: string[] } {
|
||||||
|
filetypeList = filetypeList && filetypeList.trim();
|
||||||
|
|
||||||
|
if (!filetypeList || filetypeList == '*') {
|
||||||
|
// All types supported, return undefined.
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const filetypes = filetypeList.split(/[;, ]+/g),
|
const filetypes = filetypeList.split(/[;, ]+/g),
|
||||||
mimetypes = {}, // Use an object to prevent duplicates.
|
mimetypes = {}, // Use an object to prevent duplicates.
|
||||||
typesInfo = [];
|
typesInfo = [];
|
||||||
|
|
Loading…
Reference in New Issue