本文整理匯總了TypeScript中@core/fileuploader/providers/helper.CoreFileUploaderHelperProvider類的典型用法代碼示例。如果您正苦於以下問題:TypeScript CoreFileUploaderHelperProvider類的具體用法?TypeScript CoreFileUploaderHelperProvider怎麽用?TypeScript CoreFileUploaderHelperProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了CoreFileUploaderHelperProvider類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: add
/**
* Add a new attachment.
*/
add(): void {
const allowOffline = this.allowOffline && this.allowOffline !== 'false';
if (!allowOffline && !this.appProvider.isOnline()) {
this.domUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true);
} else {
const mimetypes = this.fileTypes && this.fileTypes.mimetypes;
this.fileUploaderHelper.selectFile(this.maxSize, allowOffline, undefined, mimetypes).then((result) => {
this.files.push(result);
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'Error selecting file.');
});
}
}
示例2: uploadPrivateFile
/**
* Select a file, upload it and move it to private files.
*
* @param {any} [info] Private files info. See AddonFilesProvider.getPrivateFilesInfo.
* @return {Promise<any>} Promise resolved when a file is uploaded, rejected otherwise.
*/
uploadPrivateFile(info?: any): Promise<any> {
// Calculate the max size.
const currentSite = this.sitesProvider.getCurrentSite();
let maxSize = currentSite.getInfo().usermaxuploadfilesize,
userQuota = currentSite.getInfo().userquota;
if (userQuota === 0) {
// 0 means ignore user quota. In the app it is -1.
userQuota = -1;
} else if (userQuota > 0 && typeof info != 'undefined') {
userQuota = userQuota - info.filesizewithoutreferences;
}
if (typeof userQuota != 'undefined') {
// Use the minimum value.
maxSize = Math.min(maxSize, userQuota);
}
// Select and upload the file.
return this.fileUploaderHelper.selectAndUploadFile(maxSize).then((result) => {
if (!result) {
return Promise.reject(null);
}
// File uploaded. Move it to private files.
const modal = this.domUtils.showModalLoading('core.fileuploader.uploading', true);
return this.filesProvider.moveFromDraftToPrivate(result.itemid).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.fileuploader.errorwhileuploading', true);
return Promise.reject(null);
}).finally(() => {
modal.dismiss();
});
}).then(() => {
this.domUtils.showToast('core.fileuploader.fileuploaded', true, undefined, 'core-toast-success');
});
}