From 73751029610cd1f9fbe2d193132100ad4d2d4326 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 6 Jul 2020 10:21:00 +0200 Subject: [PATCH] MOBILE-3473 upload: Fix big files not uploaded --- .../fileuploader/providers/file-handler.ts | 18 +++--------------- src/core/fileuploader/providers/helper.ts | 8 ++++---- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/core/fileuploader/providers/file-handler.ts b/src/core/fileuploader/providers/file-handler.ts index 257110258..54c689ebe 100644 --- a/src/core/fileuploader/providers/file-handler.ts +++ b/src/core/fileuploader/providers/file-handler.ts @@ -64,12 +64,10 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler { * @return Data. */ getData(): CoreFileUploaderHandlerData { - const isIOS = this.platform.is('ios'); - const handler: CoreFileUploaderHandlerData = { - title: isIOS ? 'core.fileuploader.more' : 'core.fileuploader.file', + title: 'core.fileuploader.file', class: 'core-fileuploader-file-handler', - icon: isIOS ? 'more' : 'folder', + icon: 'folder', }; if (this.appProvider.isMobile()) { @@ -98,7 +96,6 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler { input.addEventListener('change', (evt: Event) => { const file = input.files[0]; - let fileName; input.value = ''; // Unset input. if (!file) { @@ -113,17 +110,8 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler { return; } - fileName = file.name; - if (isIOS) { - // Check the name of the file and add a timestamp if needed (take picture). - const matches = fileName.match(/image\.(jpe?g|png)/); - if (matches) { - fileName = 'image_' + this.timeUtils.readableTimestamp() + '.' + matches[1]; - } - } - // Upload the picked file. - this.uploaderHelper.uploadFileObject(file, maxSize, upload, allowOffline, fileName).then((result) => { + this.uploaderHelper.uploadFileObject(file, maxSize, upload, allowOffline, file.name).then((result) => { this.uploaderHelper.fileUploaded(result); }).catch((error) => { this.domUtils.showErrorModalDefault(error, diff --git a/src/core/fileuploader/providers/helper.ts b/src/core/fileuploader/providers/helper.ts index c3a5d7d44..4064c3829 100644 --- a/src/core/fileuploader/providers/helper.ts +++ b/src/core/fileuploader/providers/helper.ts @@ -65,8 +65,12 @@ export class CoreFileUploaderHelperProvider { */ async chooseAndUploadFile(maxSize: number, upload?: boolean, allowOffline?: boolean, mimetypes?: string[]): Promise { + const modal = this.domUtils.showModalLoading(); + const result = await this.fileChooser.getFile(mimetypes ? mimetypes.join(',') : undefined); + modal.dismiss(); + if (!result) { // User canceled. throw this.domUtils.createCanceledError(); @@ -87,10 +91,6 @@ export class CoreFileUploaderHelperProvider { const options = this.fileUploaderProvider.getFileUploadOptions(result.uri, result.name, result.mediaType, true); if (upload) { - const size = await this.fileProvider.getExternalFileSize(result.uri); - - await this.confirmUploadFile(size, false, allowOffline); - return this.uploadFile(result.uri, maxSize, true, options); } else { return this.copyToTmpFolder(result.uri, false, maxSize, undefined, options);