MOBILE-3641 core: Support CoreWSStoredFile in the whole app

main
Dani Palou 2021-04-16 15:15:21 +02:00
parent 6a846488ee
commit 163647b165
87 changed files with 410 additions and 394 deletions

View File

@ -24,7 +24,7 @@ import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/service
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper';
import { CoreFilepool } from '@services/filepool';
import { CoreSites } from '@services/sites';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonBlog } from '../blog';
import { AddonBlogMainMenuHandlerService } from './mainmenu';
@ -89,7 +89,7 @@ export class AddonBlogCourseOptionHandlerService implements CoreCourseOptionsHan
const result = await AddonBlog.getEntries({ courseid: course.id });
await Promise.all(result.entries.map(async (entry) => {
let files: CoreWSExternalFile[] = [];
let files: CoreWSFile[] = [];
if (entry.attachmentfiles && entry.attachmentfiles.length) {
files = entry.attachmentfiles;

View File

@ -15,7 +15,7 @@
import { Component, Input, OnInit, ViewChild, Type } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { ModalController } from '@singletons';
import { AddonModAssignFeedbackCommentsTextData } from '../../feedback/comments/services/handler';
import {
@ -53,7 +53,7 @@ export class AddonModAssignFeedbackPluginComponent implements OnInit {
// Data to render the plugin if it isn't supported.
component = AddonModAssignProvider.COMPONENT;
text = '';
files: CoreWSExternalFile[] = [];
files: CoreWSFile[] = [];
notSupported = false;
pluginLoaded = false;

View File

@ -14,7 +14,6 @@
import { Component, Input, OnInit, Type, ViewChild } from '@angular/core';
import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component';
import { CoreWSExternalFile } from '@services/ws';
import {
AddonModAssignAssign,
AddonModAssignSubmission,
@ -24,7 +23,7 @@ import {
} from '../../services/assign';
import { AddonModAssignHelper, AddonModAssignPluginConfig } from '../../services/assign-helper';
import { AddonModAssignSubmissionDelegate } from '../../services/submission-delegate';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFileEntry } from '@services/file-helper';
/**
* Component that displays an assignment submission plugin.
@ -49,7 +48,7 @@ export class AddonModAssignSubmissionPluginComponent implements OnInit {
// Data to render the plugin if it isn't supported.
component = AddonModAssignProvider.COMPONENT;
text = '';
files: (FileEntry | CoreWSExternalFile)[] = [];
files: CoreFileEntry[] = [];
notSupported = false;
pluginLoaded = false;

View File

@ -25,7 +25,7 @@ import { Injectable, Type } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModAssignFeedbackCommentsComponent } from '../component/comments';
@ -126,7 +126,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
assign: AddonModAssignAssign,
submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin,
): CoreWSExternalFile[] {
): CoreWSFile[] {
return AddonModAssign.getSubmissionPluginAttachments(plugin);
}

View File

@ -15,7 +15,7 @@
import { AddonModAssignFeedbackPluginComponent } from '@addons/mod/assign/components/feedback-plugin/feedback-plugin';
import { AddonModAssignProvider, AddonModAssign } from '@addons/mod/assign/services/assign';
import { Component, OnInit } from '@angular/core';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
/**
* Component to render a edit pdf feedback plugin.
@ -27,7 +27,7 @@ import { CoreWSExternalFile } from '@services/ws';
export class AddonModAssignFeedbackEditPdfComponent extends AddonModAssignFeedbackPluginComponent implements OnInit {
component = AddonModAssignProvider.COMPONENT;
files: CoreWSExternalFile[] = [];
files: CoreWSFile[] = [];
/**
* Component being initialized.

View File

@ -20,7 +20,7 @@ import {
} from '@addons/mod/assign/services/assign';
import { AddonModAssignFeedbackHandler } from '@addons/mod/assign/services/feedback-delegate';
import { Injectable, Type } from '@angular/core';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModAssignFeedbackEditPdfComponent } from '../component/editpdf';
@ -56,7 +56,7 @@ export class AddonModAssignFeedbackEditPdfHandlerService implements AddonModAssi
assign: AddonModAssignAssign,
submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin,
): CoreWSExternalFile[] {
): CoreWSFile[] {
return AddonModAssign.getSubmissionPluginAttachments(plugin);
}

View File

@ -15,7 +15,7 @@
import { AddonModAssignFeedbackPluginComponent } from '@addons/mod/assign/components/feedback-plugin/feedback-plugin';
import { AddonModAssign, AddonModAssignProvider } from '@addons/mod/assign/services/assign';
import { Component, OnInit } from '@angular/core';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
/**
* Component to render a file feedback plugin.
@ -27,7 +27,7 @@ import { CoreWSExternalFile } from '@services/ws';
export class AddonModAssignFeedbackFileComponent extends AddonModAssignFeedbackPluginComponent implements OnInit {
component = AddonModAssignProvider.COMPONENT;
files: CoreWSExternalFile[] = [];
files: CoreWSFile[] = [];
/**
* Component being initialized.

View File

@ -20,7 +20,7 @@ import {
} from '@addons/mod/assign/services/assign';
import { AddonModAssignFeedbackHandler } from '@addons/mod/assign/services/feedback-delegate';
import { Injectable, Type } from '@angular/core';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModAssignFeedbackFileComponent } from '../component/file';
@ -56,7 +56,7 @@ export class AddonModAssignFeedbackFileHandlerService implements AddonModAssignF
assign: AddonModAssignAssign,
submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin,
): CoreWSExternalFile[] {
): CoreWSFile[] {
return AddonModAssign.getSubmissionPluginAttachments(plugin);
}

View File

@ -15,7 +15,6 @@
import { Injectable } from '@angular/core';
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreWSExternalFile } from '@services/ws';
import { FileEntry } from '@ionic-native/file/ngx';
import {
AddonModAssignProvider,
@ -36,6 +35,7 @@ import { AddonModAssignSubmissionDelegate } from './submission-delegate';
import { AddonModAssignFeedbackDelegate } from './feedback-delegate';
import { makeSingleton } from '@singletons';
import { CoreFormFields } from '@singletons/form';
import { CoreFileEntry } from '@services/file-helper';
/**
* Service that provides some helper functions for assign.
@ -642,7 +642,7 @@ export class AddonModAssignHelperProvider {
async storeSubmissionFiles(
assignId: number,
folderName: string,
files: (CoreWSExternalFile | FileEntry)[],
files: CoreFileEntry[],
userId?: number,
siteId?: string,
): Promise<CoreFileUploaderStoreFilesResult> {
@ -661,7 +661,7 @@ export class AddonModAssignHelperProvider {
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with the itemId.
*/
uploadFile(assignId: number, file: CoreWSExternalFile | FileEntry, itemId?: number, siteId?: string): Promise<number> {
uploadFile(assignId: number, file: CoreFileEntry, itemId?: number, siteId?: string): Promise<number> {
return CoreFileUploader.uploadOrReuploadFile(file, itemId, AddonModAssignProvider.COMPONENT, assignId, siteId);
}
@ -675,7 +675,7 @@ export class AddonModAssignHelperProvider {
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with the itemId.
*/
uploadFiles(assignId: number, files: (CoreWSExternalFile | FileEntry)[], siteId?: string): Promise<number> {
uploadFiles(assignId: number, files: CoreFileEntry[], siteId?: string): Promise<number> {
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModAssignProvider.COMPONENT, assignId, siteId);
}
@ -693,7 +693,7 @@ export class AddonModAssignHelperProvider {
async uploadOrStoreFiles(
assignId: number,
folderName: string,
files: (CoreWSExternalFile | FileEntry)[],
files: CoreFileEntry[],
offline = false,
userId?: number,
siteId?: string,

View File

@ -53,7 +53,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
protected componentTranslatableString = 'assign';
constructor() {
super('AddonModLessonSyncProvider');
super('AddonModAssignSyncProvider');
}
/**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreInterceptor } from '@classes/interceptor';
import { CoreWSExternalWarning, CoreWSExternalFile } from '@services/ws';
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreTextUtils } from '@services/utils/text';
@ -405,12 +405,12 @@ export class AddonModAssignProvider {
* @param submissionPlugin Submission plugin.
* @return Submission plugin attachments.
*/
getSubmissionPluginAttachments(submissionPlugin: AddonModAssignPlugin): CoreWSExternalFile[] {
getSubmissionPluginAttachments(submissionPlugin: AddonModAssignPlugin): CoreWSFile[] {
if (!submissionPlugin.fileareas) {
return [];
}
const files: CoreWSExternalFile[] = [];
const files: CoreWSFile[] = [];
submissionPlugin.fileareas.forEach((filearea) => {
if (!filearea || !filearea.files) {

View File

@ -17,7 +17,7 @@ import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { AddonModAssignDefaultFeedbackHandler } from './handlers/default-feedback';
import { AddonModAssignAssign, AddonModAssignSubmission, AddonModAssignPlugin, AddonModAssignSavePluginData } from './assign';
import { makeSingleton } from '@singletons';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { AddonModAssignSubmissionFormatted } from './assign-helper';
import { CoreFormFields } from '@singletons/form';
@ -79,7 +79,7 @@ export interface AddonModAssignFeedbackHandler extends CoreDelegateHandler {
submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin,
siteId?: string,
): CoreWSExternalFile[] | Promise<CoreWSExternalFile[]>;
): CoreWSFile[] | Promise<CoreWSFile[]>;
/**
* Get a readable name to use for the plugin.
@ -246,8 +246,8 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate<AddonMod
submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin,
siteId?: string,
): Promise<CoreWSExternalFile[]> {
const files: CoreWSExternalFile[] | undefined =
): Promise<CoreWSFile[]> {
const files: CoreWSFile[] | undefined =
await this.executeFunctionOnEnabled(plugin.type, 'getPluginFiles', [assign, submission, plugin, siteId]);
return files || [];

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { Translate } from '@singletons';
import { AddonModAssignPlugin } from '../assign';
import { AddonModAssignFeedbackHandler } from '../feedback-delegate';
@ -52,7 +52,7 @@ export class AddonModAssignDefaultFeedbackHandler implements AddonModAssignFeedb
*
* @return The files (or promise resolved with the files).
*/
getPluginFiles(): CoreWSExternalFile[] {
getPluginFiles(): CoreWSFile[] {
return [];
}

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { Translate } from '@singletons';
import { AddonModAssignPlugin } from '../assign';
import { AddonModAssignSubmissionHandler } from '../submission-delegate';
@ -79,7 +79,7 @@ export class AddonModAssignDefaultSubmissionHandler implements AddonModAssignSub
*
* @return The files (or promise resolved with the files).
*/
getPluginFiles(): CoreWSExternalFile[] {
getPluginFiles(): CoreWSFile[] {
return [];
}

View File

@ -26,7 +26,7 @@ import { AddonModAssignSubmissionDelegate } from '../submission-delegate';
import { AddonModAssignFeedbackDelegate } from '../feedback-delegate';
import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler';
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { AddonModAssignHelper, AddonModAssignSubmissionFormatted } from '../assign-helper';
import { CoreCourseHelper } from '@features/course/services/course-helper';
import { CoreUtils } from '@services/utils/utils';
@ -82,13 +82,13 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
* @param courseId Course ID the module belongs to.
* @return Promise resolved with the list of files.
*/
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
const siteId = CoreSites.getCurrentSiteId();
try {
const assign = await AddonModAssign.getAssignment(courseId, module.id, { siteId });
// Get intro files and attachments.
let files = assign.introattachments || [];
let files: CoreWSFile[] = assign.introattachments || [];
files = files.concat(this.getIntroFilesFromInstance(module, assign));
// Now get the files in the submissions.
@ -145,7 +145,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
submitId: number,
blindMarking: boolean,
siteId?: string,
): Promise<CoreWSExternalFile[]> {
): Promise<CoreWSFile[]> {
const submissionStatus = await AddonModAssign.getSubmissionStatusWithRetry(assign, {
userId: submitId,
@ -158,7 +158,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
return [];
}
const promises: Promise<CoreWSExternalFile[]>[] = [];
const promises: Promise<CoreWSFile[]>[] = [];
if (userSubmission.plugins) {
// Add submission plugin files.
@ -245,7 +245,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
// Get assignment to retrieve all its submissions.
const assign = await AddonModAssign.getAssignment(courseId, module.id, options);
const promises: Promise<any>[] = [];
const promises: Promise<unknown>[] = [];
const blindMarking = assign.blindmarking && !assign.revealidentities;
if (blindMarking) {
@ -259,7 +259,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
promises.push(CoreCourseHelper.getModuleCourseIdByInstance(assign.id, 'assign', siteId));
// Download intro files and attachments. Do not call getFiles because it'd call some WS twice.
let files = assign.introattachments || [];
let files: CoreWSFile[] = assign.introattachments || [];
files = files.concat(this.getIntroFilesFromInstance(module, assign));
promises.push(CoreFilepool.addFilesToQueue(siteId, files, this.component, module.id));
@ -293,7 +293,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
// Get submissions.
const submissions = await AddonModAssign.getSubmissions(assign.id, modOptions);
const promises: Promise<any>[] = [];
const promises: Promise<unknown>[] = [];
promises.push(this.prefetchParticipantSubmissions(
assign,
@ -359,7 +359,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
AddonModAssignHelper.getSubmissionsUserData(assign, submissions, group.id, options)
.then((submissions: AddonModAssignSubmissionFormatted[]) => {
const subPromises: Promise<any>[] = submissions.map((submission) => {
const subPromises: Promise<unknown>[] = submissions.map((submission) => {
const submissionOptions = {
userId: submission.submitid,
groupId: group.id,
@ -426,7 +426,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
const userId = options.userId;
try {
const promises: Promise<any>[] = [];
const promises: Promise<unknown>[] = [];
const blindMarking = !!assign.blindmarking && !assign.revealidentities;
let userIds: number[] = [];
const userSubmission = AddonModAssign.getSubmissionObjectFromAttempt(assign, submission.lastattempt);

View File

@ -17,7 +17,7 @@ import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { AddonModAssignDefaultSubmissionHandler } from './handlers/default-submission';
import { AddonModAssignAssign, AddonModAssignSubmission, AddonModAssignPlugin, AddonModAssignSavePluginData } from './assign';
import { makeSingleton } from '@singletons';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { AddonModAssignSubmissionsDBRecordFormatted } from './assign-offline';
import { CoreFormFields } from '@singletons/form';
@ -139,7 +139,7 @@ export interface AddonModAssignSubmissionHandler extends CoreDelegateHandler {
submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin,
siteId?: string,
): CoreWSExternalFile[] | Promise<CoreWSExternalFile[]>;
): CoreWSFile[] | Promise<CoreWSFile[]>;
/**
* Get a readable name to use for the plugin.
@ -384,8 +384,8 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate<AddonM
submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin,
siteId?: string,
): Promise<CoreWSExternalFile[]> {
const files: CoreWSExternalFile[] | undefined =
): Promise<CoreWSFile[]> {
const files: CoreWSFile[] | undefined =
await this.executeFunctionOnEnabled(plugin.type, 'getPluginFiles', [assign, submission, plugin, siteId]);
return files || [];

View File

@ -24,10 +24,10 @@ import { AddonModAssignOffline, AddonModAssignSubmissionsDBRecordFormatted } fro
import { AddonModAssignSubmissionHandler } from '@addons/mod/assign/services/submission-delegate';
import { Injectable, Type } from '@angular/core';
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreFileHelper } from '@services/file-helper';
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
import { CoreFileSession } from '@services/file-session';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModAssignSubmissionFileComponent } from '../component/file';
import { FileEntry } from '@ionic-native/file/ngx';
@ -156,7 +156,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
assign: AddonModAssignAssign,
submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin,
): CoreWSExternalFile[] {
): CoreWSFile[] {
return AddonModAssign.getSubmissionPluginAttachments(plugin);
}
@ -350,14 +350,14 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
submission: AddonModAssignSubmission,
offlineData?: AddonModAssignSubmissionsDBRecordFormatted,
siteId?: string,
): Promise<(FileEntry | CoreWSExternalFile)[]> {
): Promise<CoreFileEntry[]> {
const filesData = <CoreFileUploaderStoreFilesResult>offlineData?.plugindata.files_filemanager;
if (!filesData) {
return [];
}
// Has some data to sync.
let files: (FileEntry | CoreWSExternalFile)[] = filesData.online || [];
let files: CoreFileEntry[] = filesData.online || [];
if (filesData.offline) {
// Has offline files, get them and add them to the list.

View File

@ -27,7 +27,7 @@ import { CoreFileHelper } from '@services/file-helper';
import { CoreSites } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonModAssignSubmissionOnlineTextComponent } from '../component/onlinetext';
@ -124,7 +124,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
assign: AddonModAssignAssign,
submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin,
): CoreWSExternalFile[] {
): CoreWSFile[] {
return AddonModAssign.getSubmissionPluginAttachments(plugin);
}

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
import { CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModBook, AddonModBookProvider } from '../book';
@ -55,7 +55,7 @@ export class AddonModBookPrefetchHandlerService extends CoreCourseResourcePrefet
* @param courseId Course ID.
* @return Promise resolved with list of intro files.
*/
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
const book = await CoreUtils.ignoreErrors(AddonModBook.getBook(courseId, module.id));
return this.getIntroFilesFromInstance(module, book);

View File

@ -19,7 +19,7 @@ import { CoreUser } from '@features/user/services/user';
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModChoice, AddonModChoiceProvider } from '../choice';
import { AddonModChoiceSync, AddonModChoiceSyncResult } from '../choice-sync';
@ -116,7 +116,7 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref
/**
* @inheritdoc
*/
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
const choice = await CoreUtils.ignoreErrors(AddonModChoice.getChoice(courseId, module.id));
return this.getIntroFilesFromInstance(module, choice);

View File

@ -15,8 +15,7 @@ import { Component } from '@angular/core';
import { AddonModDataEntryField, AddonModDataProvider } from '@addons/mod/data/services/data';
import { AddonModDataFieldPluginComponent } from '@addons/mod/data/classes/field-plugin-component';
import { CoreFileSession } from '@services/file-session';
import { CoreWSExternalFile } from '@services/ws';
import { FileEntry } from '@ionic-native/file';
import { CoreFileEntry } from '@services/file-helper';
/**
* Component to render data file field.
@ -27,7 +26,7 @@ import { FileEntry } from '@ionic-native/file';
})
export class AddonModDataFieldFileComponent extends AddonModDataFieldPluginComponent {
files: (CoreWSExternalFile | FileEntry)[] = [];
files: CoreFileEntry[] = [];
component?: string;
componentId?: number;
maxSizeBytes?: number;
@ -38,7 +37,7 @@ export class AddonModDataFieldFileComponent extends AddonModDataFieldPluginCompo
* @param value Input value.
* @return List of files.
*/
protected getFiles(value?: Partial<AddonModDataEntryField>): (CoreWSExternalFile | FileEntry)[] {
protected getFiles(value?: Partial<AddonModDataEntryField>): CoreFileEntry[] {
let files = value?.files || [];
// Reduce to first element.

View File

@ -22,12 +22,12 @@ import {
import { AddonModDataFieldHandler } from '@addons/mod/data/services/data-fields-delegate';
import { Injectable, Type } from '@angular/core';
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFileSession } from '@services/file-session';
import { CoreFormFields } from '@singletons/form';
import { CoreWSExternalFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonModDataFieldFileComponent } from '../component/file';
import { CoreFileEntry } from '@services/file-helper';
/**
* Handler for file data field plugin.
@ -77,7 +77,7 @@ export class AddonModDataFieldFileHandlerService implements AddonModDataFieldHan
/**
* @inheritdoc
*/
getFieldEditFiles(field: AddonModDataField): (CoreWSExternalFile | FileEntry)[] {
getFieldEditFiles(field: AddonModDataField): CoreFileEntry[] {
return CoreFileSession.getFiles(AddonModDataProvider.COMPONENT, field.dataid + '_' + field.id);
}

View File

@ -13,10 +13,9 @@
// limitations under the License.
import { AddonModDataEntryField, AddonModDataProvider } from '@addons/mod/data/services/data';
import { Component } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
import { CoreFileSession } from '@services/file-session';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreWSExternalFile } from '@services/ws';
import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component';
/**
@ -28,12 +27,12 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-
})
export class AddonModDataFieldPictureComponent extends AddonModDataFieldPluginComponent {
files: (CoreWSExternalFile | FileEntry)[] = [];
files: CoreFileEntry[] = [];
component?: string;
componentId?: number;
maxSizeBytes?: number;
image?: CoreWSExternalFile | FileEntry;
image?: CoreFileEntry;
entryId?: number;
imageUrl?: string;
title?: string;
@ -46,7 +45,7 @@ export class AddonModDataFieldPictureComponent extends AddonModDataFieldPluginCo
* @param value Input value.
* @return List of files.
*/
protected getFiles(value?: Partial<AddonModDataEntryField>): (CoreWSExternalFile | FileEntry)[] {
protected getFiles(value?: Partial<AddonModDataEntryField>): CoreFileEntry[] {
let files = value?.files || [];
// Reduce to first element.
@ -65,9 +64,9 @@ export class AddonModDataFieldPictureComponent extends AddonModDataFieldPluginCo
* @return File found or false.
*/
protected findFile(
files: (CoreWSExternalFile | FileEntry)[],
files: CoreFileEntry[],
filenameSeek: string,
): CoreWSExternalFile | FileEntry | undefined {
): CoreFileEntry | undefined {
return files.find((file) => ('name' in file ? file.name : file.filename) == filenameSeek) || undefined;
}
@ -130,7 +129,7 @@ export class AddonModDataFieldPictureComponent extends AddonModDataFieldPluginCo
if (this.image) {
this.imageUrl = 'name' in this.image
? this.image.toURL() // Is Offline.
: this.image.fileurl;
: CoreFileHelper.getFileUrl(this.image);
}
}, 1);

View File

@ -22,12 +22,12 @@ import {
import { AddonModDataFieldHandler } from '@addons/mod/data/services/data-fields-delegate';
import { Injectable, Type } from '@angular/core';
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFileSession } from '@services/file-session';
import { CoreFormFields } from '@singletons/form';
import { CoreWSExternalFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonModDataFieldPictureComponent } from '../component/picture';
import { CoreFileEntry } from '@services/file-helper';
/**
* Handler for picture data field plugin.
@ -88,7 +88,7 @@ export class AddonModDataFieldPictureHandlerService implements AddonModDataField
/**
* @inheritdoc
*/
getFieldEditFiles(field: AddonModDataField): (CoreWSExternalFile | FileEntry)[] {
getFieldEditFiles(field: AddonModDataField): CoreFileEntry[] {
return CoreFileSession.getFiles(AddonModDataProvider.COMPONENT, field.dataid + '_' + field.id);
}

View File

@ -16,7 +16,7 @@ import { Component } from '@angular/core';
import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component';
import { AddonModDataEntryField, AddonModDataProvider } from '@addons/mod/data/services/data';
import { CoreTextUtils } from '@services/utils/text';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
/**
* Component to render data number field.
@ -37,7 +37,7 @@ export class AddonModDataFieldTextareaComponent extends AddonModDataFieldPluginC
* @return Replaced string to be rendered.
*/
format(value?: Partial<AddonModDataEntryField>): string {
const files: CoreWSExternalFile[] = (value && <CoreWSExternalFile[]>value.files) || [];
const files: CoreWSFile[] = (value && <CoreWSFile[]>value.files) || [];
return value ? CoreTextUtils.replacePluginfileUrls(value.content || '', files) : '';
}

View File

@ -14,13 +14,13 @@
import { AddonModDataEntryField, AddonModDataField, AddonModDataSubfieldData } from '@addons/mod/data/services/data';
import { Injectable, Type } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { CoreFormFields } from '@singletons/form';
import { CoreTextUtils } from '@services/utils/text';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonModDataFieldTextHandlerService } from '../../text/services/handler';
import { AddonModDataFieldTextareaComponent } from '../component/textarea';
import { CoreFileEntry } from '@services/file-helper';
/**
* Handler for textarea data field plugin.
@ -49,7 +49,7 @@ export class AddonModDataFieldTextareaHandlerService extends AddonModDataFieldTe
const fieldName = 'f_' + field.id;
const files = this.getFieldEditFiles(field, inputData, originalFieldData);
let text = CoreTextUtils.restorePluginfileUrls(inputData[fieldName] || '', <CoreWSExternalFile[]>files);
let text = CoreTextUtils.restorePluginfileUrls(inputData[fieldName] || '', <CoreWSFile[]> files);
// Add some HTML to the text if needed.
text = CoreTextUtils.formatHtmlLines(text);
@ -83,7 +83,7 @@ export class AddonModDataFieldTextareaHandlerService extends AddonModDataFieldTe
field: AddonModDataField,
inputData: CoreFormFields,
originalFieldData: AddonModDataEntryField,
): (CoreWSExternalFile | FileEntry)[] {
): CoreFileEntry[] {
return (originalFieldData && originalFieldData.files) || [];
}
@ -116,7 +116,7 @@ export class AddonModDataFieldTextareaHandlerService extends AddonModDataFieldTe
// Take the original files since we cannot edit them on the app.
originalContent.content = CoreTextUtils.replacePluginfileUrls(
originalContent.content,
<CoreWSExternalFile[]>originalContent.files,
<CoreWSFile[]> originalContent.files,
);
}

View File

@ -22,8 +22,8 @@ import { AddonModDataEntryField,
AddonModDataSubfieldData,
} from './data';
import { CoreFormFields } from '@singletons/form';
import { CoreWSExternalFile } from '@services/ws';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFileEntry } from '@services/file-helper';
/**
* Interface that all fields handlers must implement.
@ -94,7 +94,7 @@ export interface AddonModDataFieldHandler extends CoreDelegateHandler {
field: AddonModDataField,
inputData: CoreFormFields,
originalFieldData: AddonModDataEntryField,
): (CoreWSExternalFile | FileEntry)[];
): CoreFileEntry[];
/**
* Check and get field requeriments.
@ -183,7 +183,7 @@ export class AddonModDataFieldsDelegateService extends CoreDelegate<AddonModData
field: AddonModDataField,
inputData: CoreFormFields,
originalFieldData: CoreFormFields,
): (CoreWSExternalFile | FileEntry)[] {
): CoreFileEntry[] {
return this.executeFunctionOnEnabled(field.type, 'getFieldEditFiles', [field, inputData, originalFieldData]) || [];
}

View File

@ -17,13 +17,12 @@ import { Injectable } from '@angular/core';
import { CoreCourse } from '@features/course/services/course';
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreRatingOffline } from '@features/rating/services/rating-offline';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreFormFields } from '@singletons/form';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events';
import {
@ -44,6 +43,7 @@ import {
} from './data';
import { AddonModDataFieldsDelegate } from './data-fields-delegate';
import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline';
import { CoreFileEntry } from '@services/file-helper';
/**
* Service that provides helper functions for datas.
@ -605,7 +605,7 @@ export class AddonModDataHelperProvider {
inputData: CoreFormFields,
fields: AddonModDataField[],
entryContents: AddonModDataEntryFields,
): Promise<(CoreWSExternalFile | FileEntry)[]> {
): Promise<CoreFileEntry[]> {
if (!inputData) {
return [];
}
@ -745,7 +745,7 @@ export class AddonModDataHelperProvider {
dataId: number,
entryId: number,
fieldId: number,
files: (CoreWSExternalFile | FileEntry)[],
files: CoreFileEntry[],
siteId?: string,
): Promise<CoreFileUploaderStoreFilesResult> {
// Get the folder where to store the files.
@ -771,7 +771,7 @@ export class AddonModDataHelperProvider {
itemId: number = 0,
entryId: number,
fieldId: number,
files: (CoreWSExternalFile | FileEntry)[],
files: CoreFileEntry[],
offline: boolean,
siteId?: string,
): Promise<number | CoreFileUploaderStoreFilesResult> {

View File

@ -21,13 +21,12 @@ import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreRatingSync } from '@features/rating/services/rating-sync';
import { FileEntry } from '@ionic-native/file';
import { CoreApp } from '@services/app';
import { CoreFileEntry } from '@services/file-helper';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSync } from '@services/sync';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { Translate, makeSingleton } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { AddonModDataProvider, AddonModData, AddonModDataData, AddonModDataAction } from './data';
@ -348,7 +347,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
// Upload Files if asked.
const value = CoreTextUtils.parseJSON<CoreFileUploaderStoreFilesResult>(field.value || '');
if (value.online || value.offline) {
let files: (CoreWSExternalFile | FileEntry)[] = value.online || [];
let files: CoreFileEntry[] = value.online || [];
const offlineFiles = value.offline
? await AddonModDataHelper.getStoredFiles(editAction.dataid, entryId, field.fieldid)

View File

@ -19,8 +19,8 @@ import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreRatingInfo } from '@features/rating/services/rating';
import { CoreTagItem } from '@features/tag/services/tag';
import { FileEntry } from '@ionic-native/file';
import { CoreApp } from '@services/app';
import { CoreFileEntry } from '@services/file-helper';
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
@ -1151,7 +1151,7 @@ export type AddonModDataEntryField = {
content2: string; // Contents.
content3: string; // Contents.
content4: string; // Contents.
files: (CoreWSExternalFile | FileEntry)[];
files: CoreFileEntry[];
};
/**
@ -1180,7 +1180,7 @@ export type AddonModDataSubfieldData = {
fieldid: number;
subfield?: string;
value?: unknown; // Value encoded in JSON.
files?: (CoreWSExternalFile | FileEntry)[];
files?: CoreFileEntry[];
};
/**

View File

@ -11,9 +11,9 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { CoreWSExternalFile } from '@services/ws';
import { CoreFileEntry } from '@services/file-helper';
import { AddonModDataEntryField, AddonModDataSearchEntriesAdvancedFieldFormatted, AddonModDataSubfieldData } from '../data';
import { AddonModDataFieldHandler } from '../data-fields-delegate';
@ -50,7 +50,7 @@ export class AddonModDataDefaultFieldHandler implements AddonModDataFieldHandler
/**
* @inheritdoc
*/
getFieldEditFiles(): (CoreWSExternalFile | FileEntry)[] {
getFieldEditFiles(): CoreFileEntry[] {
return [];
}

View File

@ -21,7 +21,7 @@ import { CoreGroup, CoreGroups } from '@services/groups';
import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModDataProvider, AddonModDataEntry, AddonModData, AddonModDataData } from '../data';
import { AddonModDataSync, AddonModDataSyncResult } from '../data-sync';
@ -82,10 +82,10 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
courseId: number,
omitFail: boolean,
options: CoreCourseCommonModWSOptions = {},
): Promise<{ database: AddonModDataData; groups: CoreGroup[]; entries: AddonModDataEntry[]; files: CoreWSExternalFile[]}> {
): Promise<{ database: AddonModDataData; groups: CoreGroup[]; entries: AddonModDataEntry[]; files: CoreWSFile[]}> {
let groups: CoreGroup[] = [];
let entries: AddonModDataEntry[] = [];
let files: CoreWSExternalFile[] = [];
let files: CoreWSFile[] = [];
options.cmId = options.cmId || module.id;
options.siteId = options.siteId || CoreSites.getCurrentSiteId();
@ -131,12 +131,12 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
* @param entries List of entries to get files from.
* @return List of files.
*/
protected getEntriesFiles(entries: AddonModDataEntry[]): CoreWSExternalFile[] {
let files: CoreWSExternalFile[] = [];
protected getEntriesFiles(entries: AddonModDataEntry[]): CoreWSFile[] {
let files: CoreWSFile[] = [];
entries.forEach((entry) => {
CoreUtils.objectToArray(entry.contents).forEach((content) => {
files = files.concat(<CoreWSExternalFile[]>content.files);
files = files.concat(<CoreWSFile[]>content.files);
});
});
@ -146,14 +146,14 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
/**
* @inheritdoc
*/
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
return this.getDatabaseInfoHelper(module, courseId, true).then((info) => info.files);
}
/**
* @inheritdoc
*/
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
const data = await CoreUtils.ignoreErrors(AddonModData.getDatabase(courseId, module.id));
return this.getIntroFilesFromInstance(module, data);

View File

@ -14,13 +14,14 @@
import { Component, ViewChild, ElementRef, Input, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
import { CoreFileEntry, CoreFileUploader } from '@features/fileuploader/services/fileuploader';
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { ModalController, Translate } from '@singletons';
import { AddonModForumData, AddonModForumPost, AddonModForumReply } from '@addons/mod/forum/services/forum';
import { AddonModForumHelper } from '@addons/mod/forum/services/forum-helper';
import { CoreForms } from '@singletons/form';
import { CoreFileEntry } from '@services/file-helper';
/**
* Page that displays a form to edit discussion post.

View File

@ -38,11 +38,10 @@ import {
AddonModForumProvider,
AddonModForumReply,
AddonModForumUpdateDiscussionPostWSOptionsObject,
AddonModForumWSPostAttachment,
} from '../../services/forum';
import { CoreTag } from '@features/tag/services/tag';
import { ModalController, PopoverController, Translate } from '@singletons';
import { CoreFileEntry, CoreFileUploader } from '@features/fileuploader/services/fileuploader';
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
import { IonContent } from '@ionic/angular';
import { AddonModForumSync } from '../../services/forum-sync';
import { CoreSync } from '@services/sync';
@ -54,6 +53,7 @@ import { AddonModForumPostOptionsMenuComponent } from '../post-options-menu/post
import { AddonModForumEditPostComponent } from '../edit-post/edit-post';
import { CoreRatingInfo } from '@features/rating/services/rating';
import { CoreForms } from '@singletons/form';
import { CoreFileEntry } from '@services/file-helper';
/**
* Components that shows a discussion post, its attachments and the action buttons allowed (reply, etc.).
@ -186,7 +186,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges
isEditing?: boolean,
subject?: string,
message?: string,
files?: (CoreFileEntry | AddonModForumWSPostAttachment)[],
files?: CoreFileEntry[],
isPrivate?: boolean,
): void {
// Delete the local files from the tmp folder if any.

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFileEntry, CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreUser } from '@features/user/services/user';
import { CoreApp } from '@services/app';
import { CoreFile } from '@services/file';
@ -31,6 +31,7 @@ import {
AddonModForumProvider,
} from './forum';
import { AddonModForumDiscussionOptions, AddonModForumOffline, AddonModForumOfflineReply } from './forum-offline';
import { CoreFileEntry } from '@services/file-helper';
/**
* Service that provides some features for forums.

View File

@ -16,17 +16,17 @@ import { Injectable } from '@angular/core';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFileEntry } from '@features/fileuploader/services/fileuploader';
import { CoreRatingInfo } from '@features/rating/services/rating';
import { CoreTagItem } from '@features/tag/services/tag';
import { CoreUser } from '@features/user/services/user';
import { CoreApp } from '@services/app';
import { CoreFileEntry } from '@services/file-helper';
import { CoreFilepool } from '@services/filepool';
import { CoreGroups } from '@services/groups';
import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning, CoreWSStoredFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumReplyOptions } from './forum-offline';
@ -1469,7 +1469,7 @@ export type AddonModForumPost = {
canreplyprivately?: boolean; // Whether the user can post a private reply.
};
attachment?: 0 | 1;
attachments?: (CoreFileEntry | AddonModForumWSPostAttachment)[];
attachments?: CoreFileEntry[];
messageinlinefiles?: CoreWSExternalFile[];
haswordcount?: boolean; // Haswordcount.
wordcount?: number; // Wordcount.
@ -1580,7 +1580,7 @@ export type AddonModForumReply = {
id: number;
subject: string;
message: string;
files: (CoreFileEntry | AddonModForumWSPostAttachment)[];
files: CoreFileEntry[];
};
/**
@ -1600,37 +1600,6 @@ export type AddonModForumSortOrder = {
value: number;
};
/**
* Forum post attachement data returned by web services.
*/
export type AddonModForumWSPostAttachment = {
contextid: number; // Contextid.
component: string; // Component.
filearea: string; // Filearea.
itemid: number; // Itemid.
filepath: string; // Filepath.
filename: string; // Filename.
isdir: boolean; // Isdir.
isimage: boolean; // Isimage.
timemodified: number; // Timemodified.
timecreated: number; // Timecreated.
filesize: number; // Filesize.
author: string; // Author.
license: string; // License.
filenameshort: string; // Filenameshort.
filesizeformatted: string; // Filesizeformatted.
icon: string; // Icon.
timecreatedformatted: string; // Timecreatedformatted.
timemodifiedformatted: string; // Timemodifiedformatted.
url: string; // Url.
urls: {
export?: string; // The URL used to export the attachment.
};
html: {
plagiarism?: string; // The HTML source for the Plagiarism Response.
};
};
/**
* Forum post data returned by web services.
*/
@ -1693,7 +1662,7 @@ export type AddonModForumWSPost = {
markasunread?: string; // The URL used to mark the post as unread.
discuss?: string; // Discuss.
};
attachments: AddonModForumWSPostAttachment[]; // Attachments.
attachments: CoreWSStoredFile[]; // Attachments.
tags?: { // Tags.
id: number; // The ID of the Tag.
tagid: number; // The tagid.

View File

@ -17,7 +17,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/
import { AddonModForum, AddonModForumData, AddonModForumPost, AddonModForumProvider } from '../forum';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreFilepool } from '@services/filepool';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreUser } from '@features/user/services/user';
import { CoreGroups, CoreGroupsProvider } from '@services/groups';
@ -44,7 +44,7 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
* @param single True if we're downloading a single module, false if we're downloading a whole section.
* @return Promise resolved with the list of files.
*/
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
try {
const forum = await AddonModForum.getForum(courseId, module.id);
@ -69,13 +69,13 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
* @param posts Forum posts.
* @return Files.
*/
protected getPostsFiles(posts: AddonModForumPost[]): CoreWSExternalFile[] {
let files: CoreWSExternalFile[] = [];
protected getPostsFiles(posts: AddonModForumPost[]): CoreWSFile[] {
let files: CoreWSFile[] = [];
const getInlineFiles = CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('3.2');
posts.forEach((post) => {
if (post.attachments && post.attachments.length) {
files = files.concat(post.attachments as CoreWSExternalFile[]);
files = files.concat(post.attachments as CoreWSFile[]);
}
if (getInlineFiles && post.messageinlinefiles && post.messageinlinefiles.length) {
files = files.concat(post.messageinlinefiles);

View File

@ -20,7 +20,7 @@ import { CoreUtils } from '@services/utils/utils';
import { AddonModGlossaryOffline } from './glossary-offline';
import { AddonModGlossaryNewEntry, AddonModGlossaryNewEntryWithFiles } from './glossary';
import { makeSingleton } from '@singletons';
import { CoreWSExternalFile } from '@services/ws';
import { CoreFileEntry } from '@services/file-helper';
/**
* Helper to gather some common functions for glossary.
@ -68,7 +68,7 @@ export class AddonModGlossaryHelperProvider {
*/
hasEntryDataChanged(
entry: AddonModGlossaryNewEntry,
files: (CoreWSExternalFile | FileEntry)[],
files: CoreFileEntry[],
original?: AddonModGlossaryNewEntryWithFiles,
): boolean {
if (!original || typeof original.concept == 'undefined') {
@ -98,7 +98,7 @@ export class AddonModGlossaryHelperProvider {
glossaryId: number,
entryName: string,
timeCreated: number,
files: (CoreWSExternalFile | FileEntry)[],
files: CoreFileEntry[],
siteId?: string,
): Promise<CoreFileUploaderStoreFilesResult> {
// Get the folder where to store the files.

View File

@ -14,7 +14,6 @@
import { ContextLevel } from '@/core/constants';
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreSyncBlockedError } from '@classes/base-sync';
import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
@ -24,13 +23,13 @@ import { CoreApp } from '@services/app';
import { CoreSites } from '@services/sites';
import { CoreSync } from '@services/sync';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { AddonModGlossary, AddonModGlossaryProvider } from './glossary';
import { AddonModGlossaryHelper } from './glossary-helper';
import { AddonModGlossaryOffline, AddonModGlossaryOfflineEntry } from './glossary-offline';
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
import { CoreFileEntry } from '@services/file-helper';
/**
* Service to sync glossaries.
@ -309,7 +308,7 @@ export class AddonModGlossarySyncProvider extends CoreCourseActivitySyncBaseProv
}
// Has some attachments to sync.
let files: (CoreWSExternalFile | FileEntry)[] = entry.attachments.online || [];
let files: CoreFileEntry[] = entry.attachments.online || [];
if (entry.attachments.offline) {
// Has offline files.

View File

@ -13,7 +13,6 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
@ -30,6 +29,7 @@ import { makeSingleton, Translate } from '@singletons';
import { AddonModGlossaryEntryDBRecord, ENTRIES_TABLE_NAME } from './database/glossary';
import { AddonModGlossaryOffline } from './glossary-offline';
import { AddonModGlossaryAutoSyncData, AddonModGlossarySyncProvider } from './glossary-sync';
import { CoreFileEntry } from '@services/file-helper';
const ROOT_CACHE_KEY = 'mmaModGlossary:';
@ -1431,7 +1431,7 @@ export type AddonModGlossaryNewEntry = {
* Entry to be added, including attachments.
*/
export type AddonModGlossaryNewEntryWithFiles = AddonModGlossaryNewEntry & {
files: (CoreWSExternalFile | FileEntry)[];
files: CoreFileEntry[];
};
/**

View File

@ -19,7 +19,7 @@ import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/c
import { CoreUser } from '@features/user/services/user';
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModGlossary, AddonModGlossaryEntry, AddonModGlossaryGlossary, AddonModGlossaryProvider } from '../glossary';
import { AddonModGlossarySync, AddonModGlossarySyncResult } from '../glossary-sync';
@ -38,7 +38,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
/**
* @inheritdoc
*/
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
try {
const glossary = await AddonModGlossary.getGlossary(courseId, module.id);
@ -68,7 +68,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
module: CoreCourseAnyModuleData,
glossary: AddonModGlossaryGlossary,
entries: AddonModGlossaryEntry[],
): CoreWSExternalFile[] {
): CoreWSFile[] {
let files = this.getIntroFilesFromInstance(module, glossary);
const getInlineFiles = CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('3.2');

View File

@ -30,7 +30,7 @@ import { CoreFilepool } from '@services/filepool';
import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import {
AddonModH5PActivity,
@ -43,6 +43,7 @@ import {
AddonModH5PActivitySyncProvider,
AddonModH5PActivitySyncResult,
} from '../../services/h5pactivity-sync';
import { CoreFileHelper } from '@services/file-helper';
/**
* Component that displays an H5P activity entry page.
@ -58,7 +59,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
h5pActivity?: AddonModH5PActivityData; // The H5P activity object.
accessInfo?: AddonModH5PActivityAccessInfo; // Info about the user capabilities.
deployedFile?: CoreWSExternalFile; // The H5P deployed file.
deployedFile?: CoreWSFile; // The H5P deployed file.
stateMessage?: string; // Message about the file state.
downloading = false; // Whether the H5P file is being downloaded.
@ -191,10 +192,10 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
siteId: this.siteId,
});
this.fileUrl = this.deployedFile.fileurl;
this.fileUrl = CoreFileHelper.getFileUrl(this.deployedFile);
// Listen for changes in the state.
const eventName = await CoreFilepool.getFileEventNameByUrl(this.site.getId(), this.deployedFile.fileurl);
const eventName = await CoreFilepool.getFileEventNameByUrl(this.site.getId(), this.fileUrl);
if (!this.observer) {
this.observer = CoreEvents.on(eventName, () => {
@ -213,7 +214,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
protected async calculateFileState(): Promise<void> {
this.state = await CoreFilepool.getFileStateByUrl(
this.site.getId(),
this.deployedFile!.fileurl,
this.fileUrl!,
this.deployedFile!.timemodified,
);
@ -317,7 +318,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
try {
await CoreFilepool.downloadUrl(
this.site.getId(),
this.deployedFile!.fileurl,
this.fileUrl!,
false,
this.component,
this.componentId,

View File

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreWSExternalWarning, CoreWSExternalFile } from '@services/ws';
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
@ -305,7 +305,7 @@ export class AddonModH5PActivityProvider {
async getDeployedFile(
h5pActivity: AddonModH5PActivityData,
options?: AddonModH5PActivityGetDeployedFileOptions,
): Promise<CoreWSExternalFile> {
): Promise<CoreWSFile> {
if (h5pActivity.deployedfile) {
// File already deployed and still valid, use this one.

View File

@ -21,7 +21,7 @@ import { CoreH5P } from '@features/h5p/services/h5p';
import { CoreUser } from '@features/user/services/user';
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModH5PActivity, AddonModH5PActivityData, AddonModH5PActivityProvider } from '../h5pactivity';
@ -39,7 +39,7 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit
/**
* @inheritdoc
*/
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
const h5pActivity = await AddonModH5PActivity.getH5PActivity(courseId, module.id);

View File

@ -23,7 +23,7 @@ import {
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModImscp, AddonModImscpProvider } from '../imscp';
@ -58,7 +58,7 @@ export class AddonModImscpPrefetchHandlerService extends CoreCourseResourcePrefe
/**
* @inheritdoc
*/
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
// If not found, use undefined so module description is used.
const imscp = await CoreUtils.ignoreErrors(AddonModImscp.getImscp(courseId, module.id));

View File

@ -17,7 +17,7 @@ import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModLabel, AddonModLabelLabel, AddonModLabelProvider } from '../label';
@ -36,7 +36,7 @@ export class AddonModLabelPrefetchHandlerService extends CoreCourseResourcePrefe
/**
* @inheritdoc
*/
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number, ignoreCache?: boolean): Promise<CoreWSExternalFile[]> {
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number, ignoreCache?: boolean): Promise<CoreWSFile[]> {
let label: AddonModLabelLabel | undefined;
if (AddonModLabel.isGetLabelAvailableForSite()) {

View File

@ -23,7 +23,7 @@ import { CoreGroups } from '@services/groups';
import { CoreFileSizeSum, CorePluginFileDelegate } from '@services/plugin-file-delegate';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton, ModalController, Translate } from '@singletons';
import { AddonModLessonPasswordModalComponent } from '../../components/password-modal/password-modal';
import {
@ -92,7 +92,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
lesson = passwordData.lesson || lesson;
// Get intro files and media files.
let files = lesson.mediafiles || [];
let files: CoreWSFile[] = lesson.mediafiles || [];
files = files.concat(this.getIntroFilesFromInstance(module, lesson));
const result = await CorePluginFileDelegate.getFilesDownloadSize(files);
@ -289,7 +289,8 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
const promises: Promise<void>[] = [];
// Download intro files and media files.
const files = (lesson.mediafiles || []).concat(this.getIntroFilesFromInstance(module, lesson));
let files: CoreWSFile[] = (lesson.mediafiles || []);
files = files.concat(this.getIntroFilesFromInstance(module, lesson));
promises.push(CoreFilepool.addFilesToQueue(siteId, files, this.component, module.id));
if (AddonModLesson.isLessonOffline(lesson)) {
@ -495,7 +496,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
}
// Download embedded files in essays.
const files: CoreWSExternalFile[] = [];
const files: CoreWSFile[] = [];
attempt.answerpages.forEach((answerPage) => {
if (!answerPage.page || answerPage.page.qtype != AddonModLessonProvider.LESSON_PAGE_ESSAY) {
return;

View File

@ -23,7 +23,7 @@ import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModQuizAccessRuleDelegate } from '../access-rules-delegate';
import {
@ -77,7 +77,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
* @return Promise resolved with the list of files.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async getFiles(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<CoreWSExternalFile[]> {
async getFiles(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<CoreWSFile[]> {
try {
const quiz = await AddonModQuiz.getQuiz(courseId, module.id);
@ -109,9 +109,9 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
quiz: AddonModQuizQuizWSData,
attempts: AddonModQuizAttemptWSData[],
siteId?: string,
): Promise<CoreWSExternalFile[]> {
): Promise<CoreWSFile[]> {
const getInlineFiles = CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('3.2');
let files: CoreWSExternalFile[] = [];
let files: CoreWSFile[] = [];
await Promise.all(attempts.map(async (attempt) => {
if (!AddonModQuiz.isAttemptFinished(attempt.state)) {

View File

@ -22,7 +22,7 @@ import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreTextUtils } from '@services/utils/text';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonModResourceIndexComponent } from '../../components/index';
import { AddonModResource, AddonModResourceCustomData } from '../resource';
@ -142,7 +142,7 @@ export class AddonModResourceModuleHandlerService implements CoreCourseModuleHan
handlerData: CoreCourseModuleHandlerData,
): Promise<AddonResourceHandlerData> {
const promises: Promise<void>[] = [];
let infoFiles: CoreWSExternalFile[] = [];
let infoFiles: CoreWSFile[] = [];
let options: AddonModResourceCustomData = {};
// Check if the button needs to be shown or not.
@ -166,7 +166,7 @@ export class AddonModResourceModuleHandlerService implements CoreCourseModuleHan
await Promise.all(promises);
const files: (CoreCourseModuleContentFile | CoreWSExternalFile)[] = module.contents && module.contents.length
const files: (CoreCourseModuleContentFile | CoreWSFile)[] = module.contents && module.contents.length
? module.contents
: infoFiles;

View File

@ -22,7 +22,7 @@ import { CoreFilepool } from '@services/filepool';
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonModScorm, AddonModScormProvider, AddonModScormScorm } from '../scorm';
import { AddonModScormSync } from '../scorm-sync';
@ -297,7 +297,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
* @param single True if we're downloading a single module, false if we're downloading a whole section.
* @return Promise resolved with the list of files.
*/
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
try {
const scorm = await this.getScorm(module, courseId);

View File

@ -25,7 +25,7 @@ import { CoreTextUtils } from '@services/utils/text';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils';
import { CoreWS, CoreWSExternalFile, CoreWSExternalWarning, CoreWSPreSets } from '@services/ws';
import { CoreWS, CoreWSExternalFile, CoreWSExternalWarning, CoreWSFile, CoreWSPreSets } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { AddonModScormOffline } from './scorm-offline';
@ -983,8 +983,8 @@ export class AddonModScormProvider {
* @param scorm SCORM.
* @return File list.
*/
getScormFileList(scorm: AddonModScormScorm): CoreWSExternalFile[] {
const files: CoreWSExternalFile[] = [];
getScormFileList(scorm: AddonModScormScorm): CoreWSFile[] {
const files: CoreWSFile[] = [];
if (!this.isScormUnsupported(scorm) && !scorm.warningMessage) {
files.push({

View File

@ -18,7 +18,7 @@ import { CoreCourseAnyModuleData } from '@features/course/services/course';
import { CoreFilepool } from '@services/filepool';
import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModSurvey, AddonModSurveyProvider } from '../survey';
import { AddonModSurveySync, AddonModSurveySyncResult } from '../survey-sync';
@ -37,7 +37,7 @@ export class AddonModSurveyPrefetchHandlerService extends CoreCourseActivityPref
/**
* @inheritdoc
*/
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSExternalFile[]> {
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number): Promise<CoreWSFile[]> {
const survey = await CoreUtils.ignoreErrors(AddonModSurvey.getSurvey(courseId, module.id));
return this.getIntroFilesFromInstance(module, survey);

View File

@ -23,7 +23,7 @@ import { CoreSync } from '@services/sync';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { Translate } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { CoreForms } from '@singletons/form';
@ -62,7 +62,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave {
protected blockId?: string; // ID to block the subwiki.
protected editing = false; // Whether the user is editing a page (true) or creating a new one (false).
protected editOffline = false; // Whether the user is editing an offline page.
protected subwikiFiles: CoreWSExternalFile[] = []; // List of files of the subwiki.
protected subwikiFiles: CoreWSFile[] = []; // List of files of the subwiki.
protected originalContent?: string; // The original page content.
protected version?: number; // Page version.
protected renewLockInterval?: number; // An interval to renew the lock every certain time.

View File

@ -21,7 +21,7 @@ import { CoreGroups } from '@services/groups';
import { CoreFileSizeSum, CorePluginFileDelegate } from '@services/plugin-file-delegate';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModWiki, AddonModWikiProvider, AddonModWikiSubwikiPage } from '../wiki';
import { AddonModWikiSync, AddonModWikiSyncWikiResult } from '../wiki-sync';
@ -103,7 +103,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
courseId: number,
single?: boolean,
siteId?: string,
): Promise<CoreWSExternalFile[]> {
): Promise<CoreWSFile[]> {
siteId = siteId || CoreSites.getCurrentSiteId();
try {

View File

@ -22,7 +22,7 @@ import { CoreApp } from '@services/app';
import { CoreNavigator } from '@services/navigator';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { CoreWSExternalFile, CoreWSExternalWarning, CoreWSFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { AddonModWikiPageDBRecord } from './database/wiki';
@ -196,7 +196,7 @@ export class AddonModWikiProvider {
* @param options Other options.
* @return Promise resolved with subwiki files.
*/
async getSubwikiFiles(wikiId: number, options: AddonModWikiGetSubwikiFilesOptions = {}): Promise<CoreWSExternalFile[]> {
async getSubwikiFiles(wikiId: number, options: AddonModWikiGetSubwikiFilesOptions = {}): Promise<CoreWSFile[]> {
const site = await CoreSites.getSite(options.siteId);
const groupId = options.groupId || -1;
@ -426,10 +426,10 @@ export class AddonModWikiProvider {
* @param options Other options.
* @return Promise resolved with the list of files.
*/
async getWikiFileList(wiki: AddonModWikiWiki, options: CoreSitesCommonWSOptions = {}): Promise<CoreWSExternalFile[]> {
async getWikiFileList(wiki: AddonModWikiWiki, options: CoreSitesCommonWSOptions = {}): Promise<CoreWSFile[]> {
options.siteId = options.siteId || CoreSites.getCurrentSiteId();
let files: CoreWSExternalFile[] = [];
let files: CoreWSFile[] = [];
const modOptions = {
cmId: wiki.coursemodule,
...options, // Include all options.

View File

@ -17,7 +17,7 @@ import { Injectable, Type } from '@angular/core';
import { CoreQuestion, CoreQuestionQuestionParsed, CoreQuestionsAnswers } from '@features/question/services/question';
import { CoreQuestionHandler } from '@features/question/services/question-delegate';
import { CoreQuestionHelper, CoreQuestionQuestion } from '@features/question/services/question-helper';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonQtypeDdMarkerComponent } from '../../component/ddmarker';
@ -135,7 +135,7 @@ export class AddonQtypeDdMarkerHandlerService implements CoreQuestionHandler {
* @param usageId Usage ID.
* @return List of files or URLs.
*/
getAdditionalDownloadableFiles(question: CoreQuestionQuestionParsed, usageId?: number): CoreWSExternalFile[] {
getAdditionalDownloadableFiles(question: CoreQuestionQuestionParsed, usageId?: number): CoreWSFile[] {
const treatedQuestion: CoreQuestionQuestion = question;
CoreQuestionHelper.extractQuestionScripts(treatedQuestion, usageId);

View File

@ -20,9 +20,9 @@ import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/service
import { AddonModQuizEssayQuestion, CoreQuestionBaseComponent } from '@features/question/classes/base-question-component';
import { CoreQuestionHelper } from '@features/question/services/question-helper';
import { CoreTextUtils } from '@services/utils/text';
import { CoreWSExternalFile } from '@services/ws';
import { CoreFileSession } from '@services/file-session';
import { CoreQuestion } from '@features/question/services/question';
import { CoreFileEntry } from '@services/file-helper';
/**
* Component to render an essay question.
*/
@ -33,7 +33,7 @@ import { CoreQuestion } from '@features/question/services/question';
export class AddonQtypeEssayComponent extends CoreQuestionBaseComponent implements OnInit {
formControl?: FormControl;
attachments?: (CoreWSExternalFile | FileEntry)[];
attachments?: CoreFileEntry[];
uploadFilesSupported = false;
essayQuestion?: AddonModQuizEssayQuestion;

View File

@ -25,7 +25,7 @@ import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonQtypeEssayComponent } from '../../component/essay';
@ -81,12 +81,12 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
* @param usageId Usage ID.
* @return List of files or URLs.
*/
getAdditionalDownloadableFiles(question: CoreQuestionQuestionParsed): CoreWSExternalFile[] {
getAdditionalDownloadableFiles(question: CoreQuestionQuestionParsed): CoreWSFile[] {
if (!question.responsefileareas) {
return [];
}
return question.responsefileareas.reduce((urlsList, area) => urlsList.concat(area.files || []), <CoreWSExternalFile[]> []);
return question.responsefileareas.reduce((urlsList, area) => urlsList.concat(area.files || []), <CoreWSFile[]> []);
}
/**

View File

@ -18,11 +18,11 @@ import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFileUploader, CoreFileUploaderTypeList } from '@features/fileuploader/services/fileuploader';
import { CoreSites } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreWSExternalFile } from '@services/ws';
import { Translate } from '@singletons';
import { CoreApp } from '@services/app';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper';
import { CoreFileEntry } from '@services/file-helper';
/**
* Component to render attachments, allow adding more and delete the current ones.
@ -43,7 +43,7 @@ import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuplo
})
export class CoreAttachmentsComponent implements OnInit {
@Input() files?: (CoreWSExternalFile | FileEntry)[]; // List of attachments. New attachments will be added to this array.
@Input() files?: CoreFileEntry[]; // List of attachments. New attachments will be added to this array.
@Input() maxSize?: number; // Max size for attachments. -1 means unlimited, 0 means user max size, not defined means unknown.
@Input() maxSubmissions?: number; // Max number of attachments. -1 means unlimited, not defined means unknown limit.
@Input() component?: string; // Component the downloaded files will be linked to.

View File

@ -25,7 +25,7 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreTextUtils } from '@services/utils/text';
import { CoreConstants } from '@/core/constants';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
/**
* Component to handle a remote file. Shows the file name, icon (depending on mimetype) and a button
@ -38,7 +38,7 @@ import { CoreWSExternalFile } from '@services/ws';
})
export class CoreFileComponent implements OnInit, OnDestroy {
@Input() file?: CoreWSExternalFile; // The file.
@Input() file?: CoreWSFile; // The file.
@Input() component?: string; // Component the file belongs to.
@Input() componentId?: string | number; // Component ID.
@Input() canDelete?: boolean | string; // Whether file can be deleted.
@ -76,7 +76,7 @@ export class CoreFileComponent implements OnInit, OnDestroy {
this.alwaysDownload = CoreUtils.isTrueOrOne(this.alwaysDownload);
this.canDownload = CoreUtils.isTrueOrOne(this.canDownload);
this.fileUrl = this.file.fileurl;
this.fileUrl = CoreFileHelper.getFileUrl(this.file);
this.timemodified = this.file.timemodified || 0;
this.siteId = CoreSites.getCurrentSiteId();
this.fileSize = this.file.filesize;
@ -88,12 +88,12 @@ export class CoreFileComponent implements OnInit, OnDestroy {
this.showTime = CoreUtils.isTrueOrOne(this.showTime) && this.timemodified > 0;
if (this.file.isexternalfile) {
if ('isexternalfile' in this.file && this.file.isexternalfile) {
this.alwaysDownload = true; // Always show the download button in external files.
}
this.fileIcon = this.file.mimetype ? CoreMimetypeUtils.getMimetypeIcon(this.file.mimetype) :
CoreMimetypeUtils.getFileIcon(this.fileName);
this.fileIcon = 'mimetype' in this.file && this.file.mimetype ?
CoreMimetypeUtils.getMimetypeIcon(this.file.mimetype) : CoreMimetypeUtils.getFileIcon(this.fileName);
if (this.canDownload) {
this.calculateState();

View File

@ -13,11 +13,10 @@
// limitations under the License.
import { Component, Input, OnInit, DoCheck, KeyValueDiffers } from '@angular/core';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFileEntry } from '@services/file-helper';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
/**
* Component to render a file list.
@ -31,7 +30,7 @@ import { CoreWSExternalFile } from '@services/ws';
})
export class CoreFilesComponent implements OnInit, DoCheck {
@Input() files?: (CoreWSExternalFile | FileEntry)[]; // List of files.
@Input() files?: CoreFileEntry[]; // List of files.
@Input() component?: string; // Component the downloaded files will be linked to.
@Input() componentId?: string | number; // Component ID.
@Input() alwaysDownload?: boolean | string; // Whether it should always display the refresh button when the file is downloaded.

View File

@ -15,7 +15,7 @@
import { CoreFilepool } from '@services/filepool';
import { CoreFileSizeSum, CorePluginFileDelegate } from '@services/plugin-file-delegate';
import { CoreSites } from '@services/sites';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile } from '../services/course';
import { CoreCourseModulePrefetchHandler } from '../services/module-prefetch-delegate';
@ -154,7 +154,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref
* @return Promise resolved with the list of files.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async getFiles(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<CoreWSExternalFile[]> {
async getFiles(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<CoreWSFile[]> {
// To be overridden.
return [];
}
@ -168,7 +168,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref
* @return Promise resolved with list of intro files.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number, ignoreCache?: boolean): Promise<CoreWSExternalFile[]> {
async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number, ignoreCache?: boolean): Promise<CoreWSFile[]> {
return this.getIntroFilesFromInstance(module);
}
@ -179,7 +179,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref
* @param instance The instance to get the intro files (book, assign, ...). If not defined, module will be used.
* @return List of intro files.
*/
getIntroFilesFromInstance(module: CoreCourseAnyModuleData, instance?: ModuleInstance): CoreWSExternalFile[] {
getIntroFilesFromInstance(module: CoreCourseAnyModuleData, instance?: ModuleInstance): CoreWSFile[] {
if (instance) {
if (typeof instance.introfiles != 'undefined') {
return instance.introfiles;
@ -339,6 +339,6 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref
* Properties a module instance should have to be able to retrieve its intro files.
*/
type ModuleInstance = {
introfiles?: CoreWSExternalFile[];
introfiles?: CoreWSFile[];
intro?: string;
};

View File

@ -18,7 +18,7 @@ import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { CoreApp } from '@services/app';
import { CoreFilepool } from '@services/filepool';
import { CoreSites } from '@services/sites';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '../services/course';
import { CoreCourseModulePrefetchHandlerBase } from './module-prefetch-handler';
@ -144,7 +144,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
* @return Promise resolved with the list of files.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async getFiles(module: CoreCourseWSModule, courseId: number, single?: boolean): Promise<CoreWSExternalFile[]> {
async getFiles(module: CoreCourseWSModule, courseId: number, single?: boolean): Promise<CoreWSFile[]> {
// Load module contents if needed.
await this.loadContents(module, courseId);

View File

@ -30,7 +30,7 @@ import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { makeSingleton } from '@singletons';
import { CoreEvents, CoreEventSectionStatusChangedData } from '@singletons/events';
import { CoreError } from '@classes/errors/error';
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { CoreWSFile, CoreWSExternalWarning } from '@services/ws';
import { CHECK_UPDATES_TIMES_TABLE, CoreCourseCheckUpdatesDBRecord } from './database/module-prefetch';
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
@ -458,7 +458,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
// Retrieve file size if it's downloaded.
await Promise.all(files.map(async (file) => {
const path = await CoreFilepool.getFilePathByUrl(siteId, file.fileurl || '');
const path = await CoreFilepool.getFilePathByUrl(siteId, CoreFileHelper.getFileUrl(file));
try {
const fileSize = await CoreFile.getFileSize(path);
@ -467,7 +467,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
} catch {
// Error getting size. Check if the file is being downloaded.
try {
await CoreFilepool.isFileDownloadingByUrl(siteId, file.fileurl || '');
await CoreFilepool.isFileDownloadingByUrl(siteId, CoreFileHelper.getFileUrl(file));
// If downloading, count as downloaded.
size += file.filesize || 0;
@ -523,7 +523,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
async getModuleFiles(
module: CoreCourseAnyModuleData,
courseId: number,
): Promise<(CoreWSExternalFile | CoreCourseModuleContentFile)[]> {
): Promise<(CoreWSFile | CoreCourseModuleContentFile)[]> {
const handler = this.getPrefetchHandlerFor(module);
if (handler?.getFiles) {
@ -1192,7 +1192,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
const files = await this.getModuleFiles(module, courseId);
await Promise.all(files.map(async (file) => {
await CoreUtils.ignoreErrors(CoreFilepool.removeFileByUrl(siteId, file.fileurl || ''));
await CoreUtils.ignoreErrors(CoreFilepool.removeFileByUrl(siteId, CoreFileHelper.getFileUrl(file)));
}));
}
@ -1462,7 +1462,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
* @param courseId Course ID the module belongs to.
* @return List of files, or promise resolved with the files.
*/
getFiles?(module: CoreCourseAnyModuleData, courseId: number): Promise<(CoreWSExternalFile | CoreCourseModuleContentFile)[]>;
getFiles?(module: CoreCourseAnyModuleData, courseId: number): Promise<(CoreWSFile | CoreCourseModuleContentFile)[]>;
/**
* Check if a certain module has updates based on the result of check updates.

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { CoreEvents } from '@singletons/events';

View File

@ -26,12 +26,13 @@ import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreTextUtils } from '@services/utils/text';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSFileUploadOptions, CoreWSUploadFileResult } from '@services/ws';
import { CoreWSFile, CoreWSFileUploadOptions, CoreWSUploadFileResult } from '@services/ws';
import { makeSingleton, Translate, MediaCapture, ModalController, Camera } from '@singletons';
import { CoreLogger } from '@singletons/logger';
import { CoreEmulatorCaptureMediaComponent } from '@features/emulator/components/capture-media/capture-media';
import { CoreError } from '@classes/errors/error';
import { CoreSite } from '@classes/site';
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
/**
* File upload options.
@ -80,7 +81,7 @@ export class CoreFileUploaderProvider {
* @param b Second file list.
* @return Whether both lists are different.
*/
areFileListDifferent(a: (CoreWSExternalFile | FileEntry)[], b: (CoreWSExternalFile | FileEntry)[]): boolean {
areFileListDifferent(a: CoreFileEntry[], b: CoreFileEntry[]): boolean {
a = a || [];
b = b || [];
if (a.length != b.length) {
@ -194,7 +195,7 @@ export class CoreFileUploaderProvider {
*
* @param files List of files.
*/
clearTmpFiles(files: (CoreWSExternalFile | FileEntry)[]): void {
clearTmpFiles(files: (CoreWSFile | FileEntry)[]): void {
// Delete the local files.
files.forEach((file) => {
if ('remove' in file) {
@ -275,15 +276,16 @@ export class CoreFileUploaderProvider {
* @return List of files to delete.
*/
getFilesToDelete(
originalFiles: CoreWSExternalFile[],
currentFiles: (CoreWSExternalFile | FileEntry)[],
originalFiles: CoreWSFile[],
currentFiles: CoreFileEntry[],
): { filepath: string; filename: string }[] {
const filesToDelete: { filepath: string; filename: string }[] = [];
currentFiles = currentFiles || [];
originalFiles.forEach((file) => {
const stillInList = currentFiles.some((currentFile) => (<CoreWSExternalFile> currentFile).fileurl == file.fileurl);
const stillInList = currentFiles.some((currentFile) =>
CoreFileHelper.getFileUrl(<CoreWSFile> currentFile) == CoreFileHelper.getFileUrl(file));
if (!stillInList) {
filesToDelete.push({
@ -391,8 +393,8 @@ export class CoreFileUploaderProvider {
async getStoredFilesFromOfflineFilesObject(
filesObject: CoreFileUploaderStoreFilesResult,
folderPath: string,
): Promise<(CoreWSExternalFile | FileEntry)[]> {
let files: (CoreWSExternalFile | FileEntry)[] = [];
): Promise<CoreFileEntry[]> {
let files: CoreFileEntry[] = [];
if (filesObject.online.length > 0) {
files = CoreUtils.clone(filesObject.online);
@ -550,7 +552,7 @@ export class CoreFileUploaderProvider {
*/
async storeFilesToUpload(
folderPath: string,
files: (CoreWSExternalFile | FileEntry)[],
files: CoreFileEntry[],
): Promise<CoreFileUploaderStoreFilesResult> {
const result: CoreFileUploaderStoreFilesResult = {
online: [],
@ -569,7 +571,7 @@ export class CoreFileUploaderProvider {
// It's an online file, add it to the result and ignore it.
result.online.push({
filename: file.filename,
fileurl: file.fileurl,
fileurl: CoreFileHelper.getFileUrl(file),
});
} else if (file.fullPath?.indexOf(folderPath) != -1) {
// File already in the submission folder.
@ -629,7 +631,7 @@ export class CoreFileUploaderProvider {
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with the itemId.
*/
async uploadFiles(itemId: number, files: (CoreWSExternalFile | FileEntry)[], siteId?: string): Promise<void> {
async uploadFiles(itemId: number, files: CoreFileEntry[], siteId?: string): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
if (!files || !files.length) {
@ -637,7 +639,7 @@ export class CoreFileUploaderProvider {
}
// Index the online files by name.
const usedNames: {[name: string]: (CoreWSExternalFile | FileEntry)} = {};
const usedNames: {[name: string]: CoreFileEntry} = {};
const filesToUpload: FileEntry[] = [];
files.forEach((file) => {
if (CoreUtils.isFileEntry(file)) {
@ -674,7 +676,7 @@ export class CoreFileUploaderProvider {
* @return Promise resolved with the itemId.
*/
async uploadOrReuploadFile(
file: CoreWSExternalFile | FileEntry,
file: CoreFileEntry,
itemId?: number,
component?: string,
componentId?: string | number,
@ -697,7 +699,7 @@ export class CoreFileUploaderProvider {
const path = await CoreFilepool.downloadUrl(
siteId,
file.fileurl,
CoreFileHelper.getFileUrl(file),
false,
component,
componentId,
@ -734,7 +736,7 @@ export class CoreFileUploaderProvider {
* @return Promise resolved with the itemId.
*/
async uploadOrReuploadFiles(
files: (CoreWSExternalFile | FileEntry)[],
files: CoreFileEntry[],
component?: string,
componentId?: string | number,
siteId?: string,
@ -766,7 +768,7 @@ export class CoreFileUploaderProvider {
export const CoreFileUploader = makeSingleton(CoreFileUploaderProvider);
export type CoreFileUploaderStoreFilesResult = {
online: CoreWSExternalFile[]; // List of online files.
online: CoreWSFile[]; // List of online files.
offline: number; // Number of offline files.
};
@ -779,5 +781,3 @@ export type CoreFileUploaderTypeListInfoEntry = {
name?: string;
extlist: string;
};
export type CoreFileEntry = CoreWSExternalFile | FileEntry;

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFile, CoreFileProvider } from '@services/file';
import { CoreSites } from '@services/sites';

View File

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreWSExternalWarning, CoreWSExternalFile } from '@services/ws';
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreQueueRunner } from '@classes/queue-runner';
@ -95,7 +95,7 @@ export class CoreH5PProvider {
options?: CoreH5PGetTrustedFileOptions,
ignoreCache?: boolean,
siteId?: string,
): Promise<CoreWSExternalFile> {
): Promise<CoreWSFile> {
options = options || {};

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFilepoolOnProgressCallback } from '@services/filepool';
import { CorePluginFileDownloadableResult, CorePluginFileHandler } from '@services/plugin-file-delegate';
@ -21,10 +21,11 @@ import { CoreSites } from '@services/sites';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { CoreH5P } from '../h5p';
import { Translate, makeSingleton } from '@singletons';
import { CoreH5PHelper } from '../../classes/helper';
import { CoreFileHelper } from '@services/file-helper';
/**
* Handler to treat H5P files.
@ -54,15 +55,17 @@ export class CoreH5PPluginFileHandlerService implements CorePluginFileHandler {
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with the file to use. Rejected if cannot download.
*/
async getDownloadableFile(file: CoreWSExternalFile, siteId?: string): Promise<CoreWSExternalFile> {
async getDownloadableFile(file: CoreWSFile, siteId?: string): Promise<CoreWSFile> {
const site = await CoreSites.getSite(siteId);
if (site.containsUrl(file.fileurl) && file.fileurl.match(/pluginfile\.php\/[^/]+\/core_h5p\/export\//i)) {
const fileUrl = CoreFileHelper.getFileUrl(file);
if (site.containsUrl(fileUrl) && fileUrl.match(/pluginfile\.php\/[^/]+\/core_h5p\/export\//i)) {
// It's already a deployed file, use it.
return file;
}
return CoreH5P.getTrustedH5PFile(file.fileurl, {}, false, siteId);
return CoreH5P.getTrustedH5PFile(fileUrl, {}, false, siteId);
}
/**
@ -94,7 +97,7 @@ export class CoreH5PPluginFileHandlerService implements CorePluginFileHandler {
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with the size.
*/
async getFileSize(file: CoreWSExternalFile, siteId?: string): Promise<number> {
async getFileSize(file: CoreWSFile, siteId?: string): Promise<number> {
try {
const trustedFile = await this.getDownloadableFile(file, siteId);
@ -125,7 +128,7 @@ export class CoreH5PPluginFileHandlerService implements CorePluginFileHandler {
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with a boolean and a reason why it isn't downloadable if needed.
*/
async isFileDownloadable(file: CoreWSExternalFile, siteId?: string): Promise<CorePluginFileDownloadableResult> {
async isFileDownloadable(file: CoreWSFile, siteId?: string): Promise<CorePluginFileDownloadableResult> {
const offlineDisabled = await CoreH5P.isOfflineDisabled(siteId);
if (offlineDisabled) {
@ -146,8 +149,8 @@ export class CoreH5PPluginFileHandlerService implements CorePluginFileHandler {
* @param file The file data.
* @return Whether the file should be treated by this handler.
*/
shouldHandleFile(file: CoreWSExternalFile): boolean {
return CoreMimetypeUtils.guessExtensionFromUrl(file.fileurl) == 'h5p';
shouldHandleFile(file: CoreWSFile): boolean {
return CoreMimetypeUtils.guessExtensionFromUrl(CoreFileHelper.getFileUrl(file)) == 'h5p';
}
/**

View File

@ -18,7 +18,7 @@ import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { CoreLogger } from '@singletons/logger';
import { CoreQuestionBehaviourButton, CoreQuestionHelper, CoreQuestionQuestion } from '../services/question-helper';
@ -715,7 +715,7 @@ export type AddonModQuizEssayQuestion = AddonModQuizQuestionBasicData & {
isPlainText?: boolean; // Whether the answer is plain text.
hasInlineText?: boolean; // // Whether the answer has inline text
answer?: string; // Question answer text.
attachments?: CoreWSExternalFile[]; // Question answer attachments.
attachments?: CoreWSFile[]; // Question answer attachments.
hasDraftFiles?: boolean; // Whether the question has draft files.
textarea?: AddonModQuizQuestionTextarea; // Textarea data.
formatInput?: { name: string; value: string }; // Format input data.

View File

@ -15,7 +15,7 @@
import { Injectable, Type } from '@angular/core';
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { CoreQuestionDefaultHandler } from './handlers/default-question';
import { CoreQuestionQuestionParsed, CoreQuestionsAnswers } from './question';
@ -143,7 +143,7 @@ export interface CoreQuestionHandler extends CoreDelegateHandler {
* @param usageId Usage ID.
* @return List of files or URLs.
*/
getAdditionalDownloadableFiles?(question: CoreQuestionQuestionParsed, usageId?: number): CoreWSExternalFile[];
getAdditionalDownloadableFiles?(question: CoreQuestionQuestionParsed, usageId?: number): CoreWSFile[];
/**
* Clear temporary data after the data has been saved.
@ -393,7 +393,7 @@ export class CoreQuestionDelegateService extends CoreDelegate<CoreQuestionHandle
* @param usageId Usage ID.
* @return List of files or URLs.
*/
getAdditionalDownloadableFiles(question: CoreQuestionQuestionParsed, usageId?: number): CoreWSExternalFile[] {
getAdditionalDownloadableFiles(question: CoreQuestionQuestionParsed, usageId?: number): CoreWSFile[] {
const type = this.getTypeName(question);
return this.executeFunctionOnEnabled(type, 'getAdditionalDownloadableFiles', [question, usageId]) || [];

View File

@ -15,13 +15,14 @@
import { Injectable, EventEmitter } from '@angular/core';
import { CoreFile } from '@services/file';
import { CoreFileHelper } from '@services/file-helper';
import { CoreFilepool } from '@services/filepool';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { CoreQuestion, CoreQuestionProvider, CoreQuestionQuestionParsed, CoreQuestionsAnswers } from './question';
import { CoreQuestionDelegate } from './question-delegate';
@ -394,7 +395,7 @@ export class CoreQuestionHelperProvider {
* @param html HTML code to search in.
* @return Attachments.
*/
getQuestionAttachmentsFromHtml(html: string): CoreWSExternalFile[] {
getQuestionAttachmentsFromHtml(html: string): CoreWSFile[] {
const element = CoreDomUtils.convertToElement(html);
// Remove the filemanager (area to attach files to a question).
@ -402,7 +403,7 @@ export class CoreQuestionHelperProvider {
// Search the anchors.
const anchors = Array.from(element.querySelectorAll('a'));
const attachments: CoreWSExternalFile[] = [];
const attachments: CoreWSFile[] = [];
anchors.forEach((anchor) => {
let content = anchor.innerHTML;
@ -464,7 +465,7 @@ export class CoreQuestionHelperProvider {
* @param areaName Name of the area, e.g. 'attachments'.
* @return List of files.
*/
getResponseFileAreaFiles(question: CoreQuestionQuestion, areaName: string): CoreWSExternalFile[] {
getResponseFileAreaFiles(question: CoreQuestionQuestion, areaName: string): CoreWSFile[] {
if (!question.responsefileareas) {
return [];
}
@ -642,22 +643,23 @@ export class CoreQuestionHelperProvider {
await Promise.all(files.map(async (file) => {
const timemodified = file.timemodified || 0;
const fileUrl = CoreFileHelper.getFileUrl(file);
if (treated[file.fileurl]) {
if (treated[fileUrl]) {
return;
}
treated[file.fileurl] = true;
treated[fileUrl] = true;
if (!site.canDownloadFiles() && CoreUrlUtils.isPluginFileUrl(file.fileurl)) {
if (!site.canDownloadFiles() && CoreUrlUtils.isPluginFileUrl(fileUrl)) {
return;
}
if (file.fileurl.indexOf('theme/image.php') > -1 && file.fileurl.indexOf('flagged') > -1) {
if (fileUrl.indexOf('theme/image.php') > -1 && fileUrl.indexOf('flagged') > -1) {
// Ignore flag images.
return;
}
await CoreFilepool.addToQueueByUrl(site.getId(), file.fileurl, component, componentId, timemodified);
await CoreFilepool.addToQueueByUrl(site.getId(), fileUrl, component, componentId, timemodified);
}));
}

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Component, OnInit, Input } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFile } from '@services/file';
import { ModalController, Translate } from '@singletons';

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Component, OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
import { FileEntry, DirectoryEntry } from '@ionic-native/file';
import { FileEntry, DirectoryEntry } from '@ionic-native/file/ngx';
import { IonRefresher } from '@ionic/angular';
import { Md5 } from 'ts-md5';

View File

@ -14,7 +14,7 @@
import { Component, OnInit } from '@angular/core';
import { CoreSharedFilesHelper } from '@features/sharedfiles/services/sharedfiles-helper';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFile } from '@services/file';
import { CoreNavigator } from '@services/navigator';
import { CoreSiteBasicInfo, CoreSites } from '@services/sites';

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreCanceledError } from '@classes/errors/cancelederror';
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { FileEntry, DirectoryEntry } from '@ionic-native/file';
import { FileEntry, DirectoryEntry } from '@ionic-native/file/ngx';
import { Md5 } from 'ts-md5/dist/md5';
import { SQLiteDB } from '@classes/sqlitedb';

View File

@ -13,10 +13,9 @@
// limitations under the License.
import { Component, Input } from '@angular/core';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFileEntry } from '@services/file-helper';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
import { ModalController } from '@singletons';
/**
@ -32,7 +31,7 @@ export class CoreViewerTextComponent {
@Input() content?: string; // Modal content.
@Input() component?: string; // Component to use in format-text.
@Input() componentId?: string | number; // Component ID to use in format-text.
@Input() files?: (CoreWSExternalFile | FileEntry)[]; // List of files.
@Input() files?: CoreFileEntry[]; // List of files.
@Input() filter?: boolean; // Whether to filter the text.
@Input() contextLevel?: string; // The context level.
@Input() instanceId?: number; // The instance ID related to the context.

View File

@ -13,13 +13,13 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreApp } from '@services/app';
import { CoreFile } from '@services/file';
import { CoreFilepool } from '@services/filepool';
import { CoreSites } from '@services/sites';
import { CoreWS, CoreWSExternalFile } from '@services/ws';
import { CoreWS, CoreWSFile } from '@services/ws';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils';
@ -46,7 +46,7 @@ export class CoreFileHelperProvider {
* @return Resolved on success.
*/
async downloadAndOpenFile(
file: CoreWSExternalFile,
file: CoreWSFile,
component?: string,
componentId?: string | number,
state?: string,
@ -55,7 +55,7 @@ export class CoreFileHelperProvider {
): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
const fileUrl = file.fileurl;
const fileUrl = CoreFileHelper.getFileUrl(file);
const timemodified = this.getFileTimemodified(file);
if (!this.isOpenableInApp(file)) {
@ -119,7 +119,7 @@ export class CoreFileHelperProvider {
* @return Resolved with the URL to use on success.
*/
protected async downloadFileIfNeeded(
file: CoreWSExternalFile,
file: CoreWSFile,
fileUrl: string,
component?: string,
componentId?: string | number,
@ -215,7 +215,7 @@ export class CoreFileHelperProvider {
componentId?: string | number,
timemodified?: number,
onProgress?: (event: ProgressEvent) => void,
file?: CoreWSExternalFile,
file?: CoreWSFile,
siteId?: string,
): Promise<string> {
siteId = siteId || CoreSites.getCurrentSiteId();
@ -255,10 +255,10 @@ export class CoreFileHelperProvider {
* Get the file's URL.
*
* @param file The file.
* @deprecated since 3.9.5. Get directly the fileurl instead.
* @return File URL.
*/
getFileUrl(file: CoreWSExternalFile): string | undefined {
return file.fileurl;
getFileUrl(file: CoreWSFile): string {
return 'fileurl' in file ? file.fileurl : file.url;
}
/**
@ -266,7 +266,7 @@ export class CoreFileHelperProvider {
*
* @param file The file.
*/
getFileTimemodified(file: CoreWSExternalFile): number {
getFileTimemodified(file: CoreWSFile): number {
return file.timemodified || 0;
}
@ -286,8 +286,8 @@ export class CoreFileHelperProvider {
* @param file The file to check.
* @return Whether the file should be opened in browser.
*/
shouldOpenInBrowser(file: CoreWSExternalFile): boolean {
if (!file || !file.isexternalfile || !file.mimetype) {
shouldOpenInBrowser(file: CoreWSFile): boolean {
if (!file || !('isexternalfile' in file) || !file.isexternalfile || !file.mimetype) {
return false;
}
@ -312,7 +312,7 @@ export class CoreFileHelperProvider {
* @param files The files to check.
* @return Total files size.
*/
async getTotalFilesSize(files: (CoreWSExternalFile | FileEntry)[]): Promise<number> {
async getTotalFilesSize(files: CoreFileEntry[]): Promise<number> {
let totalSize = 0;
for (const file of files) {
@ -328,14 +328,14 @@ export class CoreFileHelperProvider {
* @param file The file to check.
* @return File size.
*/
async getFileSize(file: CoreWSExternalFile | FileEntry): Promise<number> {
async getFileSize(file: CoreFileEntry): Promise<number> {
if ('filesize' in file && (file.filesize || file.filesize === 0)) {
return file.filesize;
}
// If it's a remote file. First check if we have the file downloaded since it's more reliable.
if ('filename' in file) {
const fileUrl = file.fileurl;
const fileUrl = CoreFileHelper.getFileUrl(file);
try {
const siteId = CoreSites.getCurrentSiteId();
@ -422,3 +422,5 @@ export class CoreFileHelperProvider {
export const CoreFileHelper = makeSingleton(CoreFileHelperProvider);
export type CoreFileHelperOnProgress = (event?: ProgressEvent | { calculating: true }) => void;
export type CoreFileEntry = CoreWSFile | FileEntry;

View File

@ -13,10 +13,9 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { CoreFileEntry } from '@services/file-helper';
import { CoreSites } from '@services/sites';
import { CoreWSExternalFile } from '@services/ws';
import { makeSingleton } from '@singletons';
/**
@ -29,7 +28,7 @@ import { makeSingleton } from '@singletons';
@Injectable({ providedIn: 'root' })
export class CoreFileSessionProvider {
protected files: {[siteId: string]: {[component: string]: {[id: string]: (CoreWSExternalFile | FileEntry)[]}}} = {};
protected files: {[siteId: string]: {[component: string]: {[id: string]: CoreFileEntry[]}}} = {};
/**
* Add a file to the session.
@ -39,7 +38,7 @@ export class CoreFileSessionProvider {
* @param file File to add.
* @param siteId Site ID. If not defined, current site.
*/
addFile(component: string, id: string | number, file: CoreWSExternalFile | FileEntry, siteId?: string): void {
addFile(component: string, id: string | number, file: CoreFileEntry, siteId?: string): void {
siteId = siteId || CoreSites.getCurrentSiteId();
this.initFileArea(component, id, siteId);
@ -69,7 +68,7 @@ export class CoreFileSessionProvider {
* @param siteId Site ID. If not defined, current site.
* @return Array of files in session.
*/
getFiles(component: string, id: string | number, siteId?: string): (CoreWSExternalFile | FileEntry)[] {
getFiles(component: string, id: string | number, siteId?: string): CoreFileEntry[] {
siteId = siteId || CoreSites.getCurrentSiteId();
if (this.files[siteId] && this.files[siteId][component] && this.files[siteId][component][id]) {
return this.files[siteId][component][id];
@ -107,7 +106,7 @@ export class CoreFileSessionProvider {
* @param file File to remove. The instance should be exactly the same as the one stored in session.
* @param siteId Site ID. If not defined, current site.
*/
removeFile(component: string, id: string | number, file: CoreWSExternalFile | FileEntry, siteId?: string): void {
removeFile(component: string, id: string | number, file: CoreFileEntry, siteId?: string): void {
siteId = siteId || CoreSites.getCurrentSiteId();
if (this.files[siteId] && this.files[siteId][component] && this.files[siteId][component][id]) {
const position = this.files[siteId][component][id].indexOf(file);
@ -141,7 +140,7 @@ export class CoreFileSessionProvider {
* @param newFiles Files to set.
* @param siteId Site ID. If not defined, current site.
*/
setFiles(component: string, id: string | number, newFiles: (CoreWSExternalFile | FileEntry)[], siteId?: string): void {
setFiles(component: string, id: string | number, newFiles: CoreFileEntry[], siteId?: string): void {
siteId = siteId || CoreSites.getCurrentSiteId();
this.initFileArea(component, id, siteId);

View File

@ -14,10 +14,9 @@
import { Injectable } from '@angular/core';
import { FileEntry, DirectoryEntry, Entry, Metadata, IFile } from '@ionic-native/file';
import { FileEntry, DirectoryEntry, Entry, Metadata, IFile } from '@ionic-native/file/ngx';
import { CoreApp } from '@services/app';
import { CoreWSExternalFile } from '@services/ws';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
@ -26,6 +25,7 @@ import { CoreError } from '@classes/errors/error';
import { CoreLogger } from '@singletons/logger';
import { makeSingleton, File, Zip, Platform, WebView } from '@singletons';
import { CoreFileEntry } from '@services/file-helper';
/**
* Progress event used when writing a file data into a file.
@ -1177,7 +1177,7 @@ export class CoreFileProvider {
* @param files List of used files.
* @return Promise resolved when done, rejected if failure.
*/
async removeUnusedFiles(dirPath: string, files: (CoreWSExternalFile | FileEntry)[]): Promise<void> {
async removeUnusedFiles(dirPath: string, files: CoreFileEntry[]): Promise<void> {
// Get the directory contents.
try {
const contents = await this.getDirectoryContents(dirPath);
@ -1297,7 +1297,7 @@ export class CoreFileProvider {
* @param file The file.
* @return The file name.
*/
getFileName(file: CoreWSExternalFile | FileEntry): string | undefined {
getFileName(file: CoreFileEntry): string | undefined {
return CoreUtils.isFileEntry(file) ? file.name : file.filename;
}

View File

@ -20,7 +20,7 @@ import { CoreEventPackageStatusChanged, CoreEvents } from '@singletons/events';
import { CoreFile } from '@services/file';
import { CorePluginFileDelegate } from '@services/plugin-file-delegate';
import { CoreSites } from '@services/sites';
import { CoreWS, CoreWSExternalFile } from '@services/ws';
import { CoreWS, CoreWSExternalFile, CoreWSFile } from '@services/ws';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreTextUtils } from '@services/utils/text';
@ -46,6 +46,7 @@ import {
CoreFilepoolQueueEntry,
CoreFilepoolQueueDBEntry,
} from '@services/database/filepool';
import { CoreFileHelper } from './file-helper';
/*
* Factory for handling downloading files and retrieve downloaded files.
@ -171,7 +172,7 @@ export class CoreFilepoolProvider {
*/
async addFileLinkByUrl(siteId: string, fileUrl: string, component: string, componentId?: string | number): Promise<void> {
const file = await this.fixPluginfileURL(siteId, fileUrl);
const fileId = this.getFileIdByUrl(file.fileurl);
const fileId = this.getFileIdByUrl(CoreFileHelper.getFileUrl(file));
await this.addFileLink(siteId, fileId, component, componentId);
}
@ -199,7 +200,7 @@ export class CoreFilepoolProvider {
* @param componentId An ID to use in conjunction with the component (optional).
* @return Resolved on success.
*/
addFilesToQueue(siteId: string, files: CoreWSExternalFile[], component?: string, componentId?: string | number): Promise<void> {
addFilesToQueue(siteId: string, files: CoreWSFile[], component?: string, componentId?: string | number): Promise<void> {
return this.downloadOrPrefetchFiles(siteId, files, true, false, component, componentId);
}
@ -342,7 +343,7 @@ export class CoreFilepoolProvider {
// Fix the URL and use the fixed data.
const file = await this.fixPluginfileURL(siteId, fileUrl);
fileUrl = file.fileurl;
fileUrl = CoreFileHelper.getFileUrl(file);
timemodified = file.timemodified || timemodified;
}
@ -735,7 +736,7 @@ export class CoreFilepoolProvider {
*/
downloadOrPrefetchFiles(
siteId: string,
files: CoreWSExternalFile[],
files: CoreWSFile[],
prefetch: boolean,
ignoreStale?: boolean,
component?: string,
@ -746,11 +747,11 @@ export class CoreFilepoolProvider {
// Download files.
files.forEach((file) => {
const url = file.fileurl;
const url = CoreFileHelper.getFileUrl(file);
const timemodified = file.timemodified;
const options = {
isexternalfile: file.isexternalfile,
repositorytype: file.repositorytype,
isexternalfile: 'isexternalfile' in file ? file.isexternalfile : undefined,
repositorytype: 'repositorytype' in file ? file.repositorytype : undefined,
};
let path: string | undefined;
@ -799,7 +800,7 @@ export class CoreFilepoolProvider {
*/
downloadOrPrefetchPackage(
siteId: string,
fileList: CoreWSExternalFile[],
fileList: CoreWSFile[],
prefetch: boolean,
component: string,
componentId?: string | number,
@ -822,10 +823,10 @@ export class CoreFilepoolProvider {
let packageLoaded = 0;
fileList.forEach((file) => {
const fileUrl = file.fileurl;
const fileUrl = CoreFileHelper.getFileUrl(file);
const options = {
isexternalfile: file.isexternalfile,
repositorytype: file.repositorytype,
isexternalfile: 'isexternalfile' in file ? file.isexternalfile : undefined,
repositorytype: 'repositorytype' in file ? file.repositorytype : undefined,
};
let path: string | undefined;
let promise: Promise<string | void>;
@ -924,7 +925,7 @@ export class CoreFilepoolProvider {
*/
downloadPackage(
siteId: string,
fileList: CoreWSExternalFile[],
fileList: CoreWSFile[],
component: string,
componentId?: string | number,
extra?: string,
@ -973,7 +974,7 @@ export class CoreFilepoolProvider {
}
const file = await this.fixPluginfileURL(siteId, fileUrl);
fileUrl = file.fileurl;
fileUrl = CoreFileHelper.getFileUrl(file);
timemodified = file.timemodified || timemodified;
options = Object.assign({}, options); // Create a copy to prevent modifying the original object.
@ -1158,11 +1159,15 @@ export class CoreFilepoolProvider {
* @param timemodified The timemodified of the file.
* @return Promise resolved with the file data to use.
*/
protected async fixPluginfileURL(siteId: string, fileUrl: string, timemodified: number = 0): Promise<CoreWSExternalFile> {
protected async fixPluginfileURL(siteId: string, fileUrl: string, timemodified: number = 0): Promise<CoreWSFile> {
const file = await CorePluginFileDelegate.getDownloadableFile({ fileurl: fileUrl, timemodified });
const site = await CoreSites.getSite(siteId);
file.fileurl = await site.checkAndFixPluginfileURL(file.fileurl);
if ('fileurl' in file) {
file.fileurl = await site.checkAndFixPluginfileURL(file.fileurl);
} else {
file.url = await site.checkAndFixPluginfileURL(file.url);
}
return file;
}
@ -1206,7 +1211,7 @@ export class CoreFilepoolProvider {
}
const file = await this.fixPluginfileURL(siteId, fileUrl);
const fileId = this.getFileIdByUrl(file.fileurl);
const fileId = this.getFileIdByUrl(CoreFileHelper.getFileUrl(file));
const filePath = await this.getFilePath(siteId, fileId, '');
const dirEntry = await CoreFile.getDir(filePath);
@ -1244,7 +1249,7 @@ export class CoreFilepoolProvider {
*/
getFileEventNameByUrl(siteId: string, fileUrl: string): Promise<string> {
return this.fixPluginfileURL(siteId, fileUrl).then((file) => {
const fileId = this.getFileIdByUrl(file.fileurl);
const fileId = this.getFileIdByUrl(CoreFileHelper.getFileUrl(file));
return this.getFileEventName(siteId, fileId);
});
@ -1342,7 +1347,7 @@ export class CoreFilepoolProvider {
*/
async getFilePathByUrl(siteId: string, fileUrl: string): Promise<string> {
const file = await this.fixPluginfileURL(siteId, fileUrl);
const fileId = this.getFileIdByUrl(file.fileurl);
const fileId = this.getFileIdByUrl(CoreFileHelper.getFileUrl(file));
return this.getFilePath(siteId, fileId);
}
@ -1433,7 +1438,7 @@ export class CoreFilepoolProvider {
filePath?: string,
revision?: number,
): Promise<string> {
let file: CoreWSExternalFile;
let file: CoreWSFile;
try {
file = await this.fixPluginfileURL(siteId, fileUrl, timemodified);
@ -1441,7 +1446,7 @@ export class CoreFilepoolProvider {
return CoreConstants.NOT_DOWNLOADABLE;
}
fileUrl = file.fileurl;
fileUrl = CoreFileHelper.getFileUrl(file);
timemodified = file.timemodified || timemodified;
revision = revision || this.getRevisionFromUrl(fileUrl);
const fileId = this.getFileIdByUrl(fileUrl);
@ -1527,7 +1532,7 @@ export class CoreFilepoolProvider {
const file = await this.fixPluginfileURL(siteId, fileUrl, timemodified);
fileUrl = file.fileurl;
fileUrl = CoreFileHelper.getFileUrl(file);
timemodified = file.timemodified || timemodified;
revision = revision || this.getRevisionFromUrl(fileUrl);
const fileId = this.getFileIdByUrl(fileUrl);
@ -1635,7 +1640,7 @@ export class CoreFilepoolProvider {
}
const file = await this.fixPluginfileURL(siteId, fileUrl);
const fileId = this.getFileIdByUrl(file.fileurl);
const fileId = this.getFileIdByUrl(CoreFileHelper.getFileUrl(file));
return this.getInternalUrlById(siteId, fileId);
}
@ -1693,7 +1698,7 @@ export class CoreFilepoolProvider {
*/
getPackageDirPathByUrl(siteId: string, url: string): Promise<string> {
return this.fixPluginfileURL(siteId, url).then((file) => {
const dirName = this.getPackageDirNameByUrl(file.fileurl);
const dirName = this.getPackageDirNameByUrl(CoreFileHelper.getFileUrl(file));
return this.getFilePath(siteId, dirName, '');
});
@ -1712,7 +1717,7 @@ export class CoreFilepoolProvider {
}
const file = await this.fixPluginfileURL(siteId, url);
const dirName = this.getPackageDirNameByUrl(file.fileurl);
const dirName = this.getPackageDirNameByUrl(CoreFileHelper.getFileUrl(file));
const dirPath = await this.getFilePath(siteId, dirName, '');
const dirEntry = await CoreFile.getDir(dirPath);
@ -1890,12 +1895,14 @@ export class CoreFilepoolProvider {
* @param files Package files.
* @return Highest revision.
*/
getRevisionFromFileList(files: CoreWSExternalFile[]): number {
getRevisionFromFileList(files: CoreWSFile[]): number {
let revision = 0;
files.forEach((file) => {
if (file.fileurl) {
const r = this.getRevisionFromUrl(file.fileurl);
const fileUrl = CoreFileHelper.getFileUrl(file);
if (fileUrl) {
const r = this.getRevisionFromUrl(fileUrl);
if (r > revision) {
revision = r;
}
@ -1981,7 +1988,7 @@ export class CoreFilepoolProvider {
* @param files List of files.
* @return Time modified.
*/
getTimemodifiedFromFileList(files: CoreWSExternalFile[]): number {
getTimemodifiedFromFileList(files: CoreWSFile[]): number {
let timemodified = 0;
files.forEach((file) => {
@ -2163,7 +2170,7 @@ export class CoreFilepoolProvider {
*/
async invalidateFileByUrl(siteId: string, fileUrl: string): Promise<void> {
const file = await this.fixPluginfileURL(siteId, fileUrl);
const fileId = this.getFileIdByUrl(file.fileurl);
const fileId = this.getFileIdByUrl(CoreFileHelper.getFileUrl(file));
const db = await CoreSites.getSiteDb(siteId);
@ -2250,7 +2257,7 @@ export class CoreFilepoolProvider {
*/
async isFileDownloadingByUrl(siteId: string, fileUrl: string): Promise<void> {
const file = await this.fixPluginfileURL(siteId, fileUrl);
const fileId = this.getFileIdByUrl(file.fileurl);
const fileId = this.getFileIdByUrl(CoreFileHelper.getFileUrl(file));
await this.hasFileInQueue(siteId, fileId);
}
@ -2403,7 +2410,7 @@ export class CoreFilepoolProvider {
*/
prefetchPackage(
siteId: string,
fileList: CoreWSExternalFile[],
fileList: CoreWSFile[],
component: string,
componentId?: string | number,
extra?: string,
@ -2691,7 +2698,7 @@ export class CoreFilepoolProvider {
*/
async removeFileByUrl(siteId: string, fileUrl: string): Promise<void> {
const file = await this.fixPluginfileURL(siteId, fileUrl);
const fileId = this.getFileIdByUrl(file.fileurl);
const fileId = this.getFileIdByUrl(CoreFileHelper.getFileUrl(file));
await this.removeFileById(siteId, fileId);
}

View File

@ -13,14 +13,15 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFilepool, CoreFilepoolOnProgressCallback } from '@services/filepool';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { CoreConstants } from '@/core/constants';
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { makeSingleton } from '@singletons';
import { CoreSites } from './sites';
import { CoreFileHelper } from './file-helper';
/**
* Delegate to register pluginfile information handlers.
@ -57,7 +58,7 @@ export class CorePluginFileDelegateService extends CoreDelegate<CorePluginFileHa
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with the file to use. Rejected if cannot download.
*/
getDownloadableFile(file: CoreWSExternalFile, siteId?: string): Promise<CoreWSExternalFile> {
getDownloadableFile(file: CoreWSFile, siteId?: string): Promise<CoreWSFile> {
const handler = this.getHandlerForFile(file);
return this.getHandlerDownloadableFile(file, handler, siteId);
@ -72,10 +73,10 @@ export class CorePluginFileDelegateService extends CoreDelegate<CorePluginFileHa
* @return Promise resolved with the file to use. Rejected if cannot download.
*/
protected async getHandlerDownloadableFile(
file: CoreWSExternalFile,
file: CoreWSFile,
handler?: CorePluginFileHandler,
siteId?: string,
): Promise<CoreWSExternalFile> {
): Promise<CoreWSFile> {
const isDownloadable = await this.isFileDownloadable(file, siteId);
if (!isDownloadable.downloadable) {
@ -134,13 +135,13 @@ export class CorePluginFileDelegateService extends CoreDelegate<CorePluginFileHa
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with file size and a boolean to indicate if it is the total size or only partial.
*/
async getFilesDownloadSize(files: CoreWSExternalFile[], siteId?: string): Promise<CoreFileSizeSum> {
async getFilesDownloadSize(files: CoreWSFile[], siteId?: string): Promise<CoreFileSizeSum> {
siteId = siteId || CoreSites.getCurrentSiteId();
const filteredFiles = <CoreWSExternalFile[]>[];
const filteredFiles = <CoreWSFile[]>[];
await Promise.all(files.map(async (file) => {
const state = await CoreFilepool.getFileStateByUrl(siteId!, file.fileurl, file.timemodified);
const state = await CoreFilepool.getFileStateByUrl(siteId!, CoreFileHelper.getFileUrl(file), file.timemodified);
if (state != CoreConstants.DOWNLOADED && state != CoreConstants.NOT_DOWNLOADABLE) {
filteredFiles.push(file);
@ -157,7 +158,7 @@ export class CorePluginFileDelegateService extends CoreDelegate<CorePluginFileHa
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with file size and a boolean to indicate if it is the total size or only partial.
*/
async getFilesSize(files: CoreWSExternalFile[], siteId?: string): Promise<CoreFileSizeSum> {
async getFilesSize(files: CoreWSFile[], siteId?: string): Promise<CoreFileSizeSum> {
const result = {
size: 0,
total: true,
@ -184,7 +185,7 @@ export class CorePluginFileDelegateService extends CoreDelegate<CorePluginFileHa
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with the size.
*/
async getFileSize(file: CoreWSExternalFile, siteId?: string): Promise<number> {
async getFileSize(file: CoreWSFile, siteId?: string): Promise<number> {
const isDownloadable = await this.isFileDownloadable(file, siteId);
if (!isDownloadable.downloadable) {
@ -218,7 +219,7 @@ export class CorePluginFileDelegateService extends CoreDelegate<CorePluginFileHa
* @param file File data.
* @return Handler.
*/
protected getHandlerForFile(file: CoreWSExternalFile): CorePluginFileHandler | undefined {
protected getHandlerForFile(file: CoreWSFile): CorePluginFileHandler | undefined {
for (const component in this.enabledHandlers) {
const handler = this.enabledHandlers[component];
@ -235,7 +236,7 @@ export class CorePluginFileDelegateService extends CoreDelegate<CorePluginFileHa
* @param siteId Site ID. If not defined, current site.
* @return Promise with the data.
*/
async isFileDownloadable(file: CoreWSExternalFile, siteId?: string): Promise<CorePluginFileDownloadableResult> {
async isFileDownloadable(file: CoreWSFile, siteId?: string): Promise<CorePluginFileDownloadableResult> {
const handler = this.getHandlerForFile(file);
if (handler && handler.isFileDownloadable) {
@ -337,7 +338,7 @@ export interface CorePluginFileHandler extends CoreDelegateHandler {
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with the file to use. Rejected if cannot download.
*/
getDownloadableFile?(file: CoreWSExternalFile, siteId?: string): Promise<CoreWSExternalFile>;
getDownloadableFile?(file: CoreWSFile, siteId?: string): Promise<CoreWSFile>;
/**
* Given an HTML element, get the URLs of the files that should be downloaded and weren't treated by
@ -355,7 +356,7 @@ export interface CorePluginFileHandler extends CoreDelegateHandler {
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with the size.
*/
getFileSize?(file: CoreWSExternalFile, siteId?: string): Promise<number>;
getFileSize?(file: CoreWSFile, siteId?: string): Promise<number>;
/**
* Check if a file is downloadable.
@ -364,7 +365,7 @@ export interface CorePluginFileHandler extends CoreDelegateHandler {
* @param siteId Site ID. If not defined, current site.
* @return Promise resolved with a boolean and a reason why it isn't downloadable if needed.
*/
isFileDownloadable?(file: CoreWSExternalFile, siteId?: string): Promise<CorePluginFileDownloadableResult>;
isFileDownloadable?(file: CoreWSFile, siteId?: string): Promise<CorePluginFileDownloadableResult>;
/**
* Check whether the file should be treated by this handler. It is used in functions where the component isn't used.
@ -372,7 +373,7 @@ export interface CorePluginFileHandler extends CoreDelegateHandler {
* @param file The file data.
* @return Whether the file should be treated by this handler.
*/
shouldHandleFile?(file: CoreWSExternalFile): boolean;
shouldHandleFile?(file: CoreWSFile): boolean;
/**
* Treat a downloaded file.

View File

@ -13,17 +13,18 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { CoreFile } from '@services/file';
import { CoreTextUtils } from '@services/utils/text';
import { makeSingleton, Translate } from '@singletons';
import { CoreLogger } from '@singletons/logger';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { CoreUtils } from '@services/utils/utils';
import extToMime from '@/assets/exttomime.json';
import mimeToExt from '@/assets/mimetoext.json';
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
interface MimeTypeInfo {
type: string;
@ -163,7 +164,7 @@ export class CoreMimetypeUtilsProvider {
* @param file File object.
* @param path Alternative path that will override fileurl from file object.
*/
getEmbeddedHtml(file: CoreWSExternalFile | FileEntry, path?: string): string {
getEmbeddedHtml(file: CoreFileEntry, path?: string): string {
const filename = CoreUtils.isFileEntry(file) ? (file as FileEntry).name : file.filename;
const extension = !CoreUtils.isFileEntry(file) && file.mimetype
? this.getExtension(file.mimetype)
@ -173,7 +174,7 @@ export class CoreMimetypeUtilsProvider {
: (extension && this.getMimeType(extension));
// @todo linting: See if this can be removed
(file as CoreWSExternalFile).mimetype = mimeType;
(file as CoreWSFile).mimetype = mimeType;
if (extension && this.canBeEmbedded(extension)) {
const embedType = this.getExtensionType(extension);
@ -181,7 +182,7 @@ export class CoreMimetypeUtilsProvider {
// @todo linting: See if this can be removed
(file as { embedType?: string }).embedType = embedType;
path = path ?? (CoreUtils.isFileEntry(file) ? file.toURL() : file.fileurl);
path = path ?? (CoreUtils.isFileEntry(file) ? file.toURL() : CoreFileHelper.getFileUrl(file));
path = path && CoreFile.convertFileSrc(path);
switch (embedType) {
@ -401,7 +402,7 @@ export class CoreMimetypeUtilsProvider {
* @param capitalise If true, capitalises first character of result.
* @return Type description.
*/
getMimetypeDescription(obj: FileEntry | CoreWSExternalFile | string, capitalise?: boolean): string {
getMimetypeDescription(obj: CoreFileEntry | string, capitalise?: boolean): string {
const langPrefix = 'assets.mimetypes.';
let filename: string | undefined = '';
let mimetype: string | undefined = '';

View File

@ -20,9 +20,10 @@ import { CoreApp } from '@services/app';
import { CoreLang } from '@services/lang';
import { CoreAnyError, CoreError } from '@classes/errors/error';
import { makeSingleton, ModalController, Translate } from '@singletons';
import { CoreWSExternalFile } from '@services/ws';
import { CoreWSFile } from '@services/ws';
import { Locutus } from '@singletons/locutus';
import { CoreViewerTextComponent } from '@features/viewer/components/text/text';
import { CoreFileHelper } from '@services/file-helper';
/**
* Different type of errors the app can treat.
@ -462,7 +463,7 @@ export class CoreTextUtilsProvider {
text: string,
component?: string,
componentId?: string | number,
files?: CoreWSExternalFile[],
files?: CoreWSFile[],
filter?: boolean,
contextLevel?: string,
instanceId?: number,
@ -555,9 +556,9 @@ export class CoreTextUtilsProvider {
* @param files Files to extract the URL from. They need to have the URL in a 'url' or 'fileurl' attribute.
* @return Pluginfile URL, undefined if no files found.
*/
getTextPluginfileUrl(files: CoreWSExternalFile[]): string | undefined {
getTextPluginfileUrl(files: CoreWSFile[]): string | undefined {
if (files?.length) {
const url = files[0].fileurl;
const url = CoreFileHelper.getFileUrl(files[0]);
// Remove text after last slash (encoded or not).
return url?.substr(0, Math.max(url.lastIndexOf('/'), url.lastIndexOf('%2F')));
@ -759,7 +760,7 @@ export class CoreTextUtilsProvider {
replaceDraftfileUrls(
siteUrl: string,
text: string,
files: CoreWSExternalFile[],
files: CoreWSFile[],
): { text: string; replaceMap?: {[url: string]: string} } {
if (!text || !files || !files.length) {
@ -776,7 +777,7 @@ export class CoreTextUtilsProvider {
// Index the pluginfile URLs by file name.
const pluginfileMap: {[name: string]: string} = {};
files.forEach((file) => {
pluginfileMap[file.filename!] = file.fileurl;
pluginfileMap[file.filename!] = CoreFileHelper.getFileUrl(file);
});
// Replace each draftfile with the corresponding pluginfile URL.
@ -812,7 +813,7 @@ export class CoreTextUtilsProvider {
* @param files Files to extract the pluginfile URL from. They need to have the URL in a url or fileurl attribute.
* @return Treated text.
*/
replacePluginfileUrls(text: string, files: CoreWSExternalFile[]): string {
replacePluginfileUrls(text: string, files: CoreWSFile[]): string {
if (text && typeof text == 'string') {
const fileURL = this.getTextPluginfileUrl(files);
if (fileURL) {
@ -830,7 +831,7 @@ export class CoreTextUtilsProvider {
* @param replaceMap Map of the replacements that were done.
* @return Treated text.
*/
restoreDraftfileUrls(siteUrl: string, treatedText: string, originalText: string, files: CoreWSExternalFile[]): string {
restoreDraftfileUrls(siteUrl: string, treatedText: string, originalText: string, files: CoreWSFile[]): string {
if (!treatedText || !files || !files.length) {
return treatedText;
}
@ -848,7 +849,7 @@ export class CoreTextUtilsProvider {
return; // Original URL not found, skip.
}
treatedText = treatedText.replace(new RegExp(this.escapeForRegex(file.fileurl), 'g'), matches[0]);
treatedText = treatedText.replace(new RegExp(this.escapeForRegex(CoreFileHelper.getFileUrl(file)), 'g'), matches[0]);
});
return treatedText;
@ -861,7 +862,7 @@ export class CoreTextUtilsProvider {
* @param files Files to extract the pluginfile URL from. They need to have the URL in a url or fileurl attribute.
* @return Treated text.
*/
restorePluginfileUrls(text: string, files: CoreWSExternalFile[]): string {
restorePluginfileUrls(text: string, files: CoreWSFile[]): string {
if (text && typeof text == 'string') {
const fileURL = this.getTextPluginfileUrl(files);
if (fileURL) {
@ -1103,7 +1104,7 @@ export class CoreTextUtilsProvider {
export type CoreTextUtilsViewTextOptions = {
component?: string; // Component to link the embedded files to.
componentId?: string | number; // An ID to use in conjunction with the component.
files?: CoreWSExternalFile[]; // List of files to display along with the text.
files?: CoreWSFile[]; // List of files to display along with the text.
filter?: boolean; // Whether the text should be filtered.
contextLevel?: string; // The context level.
instanceId?: number; // The instance ID related to the context.

View File

@ -14,14 +14,14 @@
import { Injectable, NgZone } from '@angular/core';
import { InAppBrowserObject, InAppBrowserOptions } from '@ionic-native/in-app-browser';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { Subscription } from 'rxjs';
import { CoreApp } from '@services/app';
import { CoreEvents } from '@singletons/events';
import { CoreFile } from '@services/file';
import { CoreLang } from '@services/lang';
import { CoreWS, CoreWSExternalFile } from '@services/ws';
import { CoreWS, CoreWSFile } from '@services/ws';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreTextUtils } from '@services/utils/text';
@ -31,6 +31,7 @@ import { CoreLogger } from '@singletons/logger';
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
import { CoreViewerQRScannerComponent } from '@features/viewer/components/qr-scanner/qr-scanner';
import { CoreCanceledError } from '@classes/errors/cancelederror';
import { CoreFileEntry } from '@services/file-helper';
type TreeNode<T> = T & { children: TreeNode<T>[] };
@ -379,11 +380,7 @@ export class CoreUtilsProvider {
/**
* Execute promises one depending on the previous.
*
* @param orderedPromisesData Data to be executed including the following values:
* - func: Function to be executed.
* - context: Context to pass to the function. This allows using "this" inside the function.
* - params: Array of data to be sent to the function.
* - blocking: Boolean. If promise should block the following.
* @param orderedPromisesData Data to be executed.
* @return Promise resolved when all promises are resolved.
*/
executeOrderedPromises(orderedPromisesData: OrderedPromiseData[]): Promise<void> {
@ -748,7 +745,7 @@ export class CoreUtilsProvider {
* @param file File.
* @return Type guard indicating if the file is a FileEntry.
*/
isFileEntry(file: FileEntry | CoreWSExternalFile): file is FileEntry {
isFileEntry(file: CoreFileEntry): file is FileEntry {
return 'isFile' in file;
}
@ -768,7 +765,7 @@ export class CoreUtilsProvider {
* @param files List of files.
* @return String with error message if repeated, false if no repeated.
*/
hasRepeatedFilenames(files: (FileEntry | CoreWSExternalFile)[]): string | false {
hasRepeatedFilenames(files: CoreFileEntry[]): string | false {
if (!files || !files.length) {
return false;
}
@ -1368,7 +1365,7 @@ export class CoreUtilsProvider {
* @return File size and a boolean to indicate if it is the total size or only partial.
* @deprecated since 3.8.0. Use CorePluginFileDelegate.getFilesSize instead.
*/
sumFileSizes(files: CoreWSExternalFile[]): CoreFileSizeSum {
sumFileSizes(files: CoreWSFile[]): CoreFileSizeSum {
const result = {
size: 0,
total: true,

View File

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core';
import { HttpResponse, HttpParams } from '@angular/common/http';
import { FileEntry } from '@ionic-native/file';
import { FileEntry } from '@ionic-native/file/ngx';
import { FileUploadOptions } from '@ionic-native/file-transfer/ngx';
import { Md5 } from 'ts-md5/dist/md5';
import { Observable } from 'rxjs';
@ -1087,6 +1087,43 @@ export type CoreWSExternalFile = {
repositorytype?: string; // The repository type for external files.
};
/**
* Structure of files returned by stored_file_exporter.
*/
export type CoreWSStoredFile = {
contextid: number; // Contextid.
component: string; // Component.
filearea: string; // Filearea.
itemid: number; // Itemid.
filepath: string; // Filepath.
filename: string; // Filename.
isdir: boolean; // Isdir.
isimage: boolean; // Isimage.
timemodified: number; // Timemodified.
timecreated: number; // Timecreated.
filesize: number; // Filesize.
author: string; // Author.
license: string; // License.
filenameshort: string; // Filenameshort.
filesizeformatted: string; // Filesizeformatted.
icon: string; // Icon.
timecreatedformatted: string; // Timecreatedformatted.
timemodifiedformatted: string; // Timemodifiedformatted.
url: string; // Url.
urls: {
export?: string; // The URL used to export the attachment.
};
html: {
plagiarism?: string; // The HTML source for the Plagiarism Response.
};
mimetype: undefined; // File mimetype. @todo Not implemented yet in Moodle, see MDL-71354.
};
/**
* Common file structures returned by WS.
*/
export type CoreWSFile = CoreWSExternalFile | CoreWSStoredFile;
/**
* Data returned by date_exporter.
*/