當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript helper.CoreFileUploaderHelperProvider類代碼示例

本文整理匯總了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.');
            });
        }
    }
開發者ID:SATS-Seminary,項目名稱:moodlemobile2,代碼行數:18,代碼來源:attachments.ts

示例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');
        });
    }
開發者ID:SATS-Seminary,項目名稱:moodlemobile2,代碼行數:44,代碼來源:helper.ts


注:本文中的@core/fileuploader/providers/helper.CoreFileUploaderHelperProvider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。