Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions src/core/fileuploader/providers/file-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/core/fileuploader/providers/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ export class CoreFileUploaderHelperProvider {
*/
async chooseAndUploadFile(maxSize: number, upload?: boolean, allowOffline?: boolean, mimetypes?: string[]): Promise<any> {

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();
Expand All @@ -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);
Expand Down