MOBILE-3657 file: Add uploadOrStoreFile overloads
parent
8d31beb0a7
commit
e024947fdd
|
@ -694,16 +694,40 @@ export class AddonModAssignHelperProvider {
|
||||||
assignId: number,
|
assignId: number,
|
||||||
folderName: string,
|
folderName: string,
|
||||||
files: CoreFileEntry[],
|
files: CoreFileEntry[],
|
||||||
offline = false,
|
offline: true,
|
||||||
|
userId?: number,
|
||||||
|
siteId?: string,
|
||||||
|
): Promise<CoreFileUploaderStoreFilesResult>;
|
||||||
|
async uploadOrStoreFiles(
|
||||||
|
assignId: number,
|
||||||
|
folderName: string,
|
||||||
|
files: CoreFileEntry[],
|
||||||
|
offline: false,
|
||||||
|
userId?: number,
|
||||||
|
siteId?: string,
|
||||||
|
): Promise<number>;
|
||||||
|
async uploadOrStoreFiles(
|
||||||
|
assignId: number,
|
||||||
|
folderName: string,
|
||||||
|
files: CoreFileEntry[],
|
||||||
|
offline: boolean,
|
||||||
|
userId?: number,
|
||||||
|
siteId?: string,
|
||||||
|
): Promise<number | CoreFileUploaderStoreFilesResult>;
|
||||||
|
async uploadOrStoreFiles(
|
||||||
|
assignId: number,
|
||||||
|
folderName: string,
|
||||||
|
files: CoreFileEntry[],
|
||||||
|
offline: boolean,
|
||||||
userId?: number,
|
userId?: number,
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
): Promise<number | CoreFileUploaderStoreFilesResult> {
|
): Promise<number | CoreFileUploaderStoreFilesResult> {
|
||||||
|
|
||||||
if (offline) {
|
if (offline) {
|
||||||
return await this.storeSubmissionFiles(assignId, folderName, files, userId, siteId);
|
return this.storeSubmissionFiles(assignId, folderName, files, userId, siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.uploadFiles(assignId, files, siteId);
|
return this.uploadFiles(assignId, files, siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,7 +278,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
|
||||||
plugin: AddonModAssignPlugin,
|
plugin: AddonModAssignPlugin,
|
||||||
inputData: AddonModAssignSubmissionFileData,
|
inputData: AddonModAssignSubmissionFileData,
|
||||||
pluginData: AddonModAssignSubmissionFilePluginData,
|
pluginData: AddonModAssignSubmissionFilePluginData,
|
||||||
offline?: boolean,
|
offline = false,
|
||||||
userId?: number,
|
userId?: number,
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|
|
@ -542,7 +542,7 @@ export class AddonModDataHelperProvider {
|
||||||
dataId: number,
|
dataId: number,
|
||||||
entryId: number,
|
entryId: number,
|
||||||
entryContents: AddonModDataEntryFields,
|
entryContents: AddonModDataEntryFields,
|
||||||
offline: boolean = false,
|
offline = false,
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
): Promise<AddonModDataEntryWSField[]> {
|
): Promise<AddonModDataEntryWSField[]> {
|
||||||
if (!inputData) {
|
if (!inputData) {
|
||||||
|
@ -766,6 +766,33 @@ export class AddonModDataHelperProvider {
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @return Promise resolved with the itemId for the uploaded file/s.
|
* @return Promise resolved with the itemId for the uploaded file/s.
|
||||||
*/
|
*/
|
||||||
|
async uploadOrStoreFiles(
|
||||||
|
dataId: number,
|
||||||
|
itemId: number,
|
||||||
|
entryId: number,
|
||||||
|
fieldId: number,
|
||||||
|
files: CoreFileEntry[],
|
||||||
|
offline: true,
|
||||||
|
siteId?: string,
|
||||||
|
): Promise<CoreFileUploaderStoreFilesResult>;
|
||||||
|
async uploadOrStoreFiles(
|
||||||
|
dataId: number,
|
||||||
|
itemId: number,
|
||||||
|
entryId: number,
|
||||||
|
fieldId: number,
|
||||||
|
files: CoreFileEntry[],
|
||||||
|
offline: false,
|
||||||
|
siteId?: string,
|
||||||
|
): Promise<number>;
|
||||||
|
async uploadOrStoreFiles(
|
||||||
|
dataId: number,
|
||||||
|
itemId: number,
|
||||||
|
entryId: number,
|
||||||
|
fieldId: number,
|
||||||
|
files: CoreFileEntry[],
|
||||||
|
offline: boolean,
|
||||||
|
siteId?: string,
|
||||||
|
): Promise<number | CoreFileUploaderStoreFilesResult>;
|
||||||
async uploadOrStoreFiles(
|
async uploadOrStoreFiles(
|
||||||
dataId: number,
|
dataId: number,
|
||||||
itemId: number = 0,
|
itemId: number = 0,
|
||||||
|
|
|
@ -287,7 +287,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges
|
||||||
const attachment = await AddonModForumHelper.uploadOrStoreReplyFiles(
|
const attachment = await AddonModForumHelper.uploadOrStoreReplyFiles(
|
||||||
this.forum.id,
|
this.forum.id,
|
||||||
this.post.id,
|
this.post.id,
|
||||||
files,
|
files as CoreFileEntry[],
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -445,11 +445,17 @@ export class AddonModForumHelperProvider {
|
||||||
* @param userId User the reply belongs to. If not defined, current user in site.
|
* @param userId User the reply belongs to. If not defined, current user in site.
|
||||||
* @return Promise resolved if success, rejected otherwise.
|
* @return Promise resolved if success, rejected otherwise.
|
||||||
*/
|
*/
|
||||||
async storeReplyFiles(forumId: number, postId: number, files: any[], siteId?: string, userId?: number): Promise<void> {
|
async storeReplyFiles(
|
||||||
|
forumId: number,
|
||||||
|
postId: number,
|
||||||
|
files: CoreFileEntry[],
|
||||||
|
siteId?: string,
|
||||||
|
userId?: number,
|
||||||
|
): Promise<CoreFileUploaderStoreFilesResult> {
|
||||||
// Get the folder where to store the files.
|
// Get the folder where to store the files.
|
||||||
const folderPath = await AddonModForumOffline.getReplyFolder(forumId, postId, siteId, userId);
|
const folderPath = await AddonModForumOffline.getReplyFolder(forumId, postId, siteId, userId);
|
||||||
|
|
||||||
await CoreFileUploader.storeFilesToUpload(folderPath, files);
|
return CoreFileUploader.storeFilesToUpload(folderPath, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -485,9 +491,9 @@ export class AddonModForumHelperProvider {
|
||||||
): Promise<CoreFileUploaderStoreFilesResult | number> {
|
): Promise<CoreFileUploaderStoreFilesResult | number> {
|
||||||
if (offline) {
|
if (offline) {
|
||||||
return this.storeNewDiscussionFiles(forumId, timecreated, files, siteId);
|
return this.storeNewDiscussionFiles(forumId, timecreated, files, siteId);
|
||||||
} else {
|
|
||||||
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModForumProvider.COMPONENT, forumId, siteId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModForumProvider.COMPONENT, forumId, siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -501,19 +507,35 @@ export class AddonModForumHelperProvider {
|
||||||
* @param userId User the reply belongs to. If not defined, current user in site.
|
* @param userId User the reply belongs to. If not defined, current user in site.
|
||||||
* @return Promise resolved if success.
|
* @return Promise resolved if success.
|
||||||
*/
|
*/
|
||||||
uploadOrStoreReplyFiles(
|
async uploadOrStoreReplyFiles(
|
||||||
forumId: number,
|
forumId: number,
|
||||||
postId: number,
|
postId: number,
|
||||||
files: any[],
|
files: CoreFileEntry[],
|
||||||
|
offline: true,
|
||||||
|
siteId?: string,
|
||||||
|
userId?: number,
|
||||||
|
): Promise<CoreFileUploaderStoreFilesResult>;
|
||||||
|
async uploadOrStoreReplyFiles(
|
||||||
|
forumId: number,
|
||||||
|
postId: number,
|
||||||
|
files: CoreFileEntry[],
|
||||||
|
offline: false,
|
||||||
|
siteId?: string,
|
||||||
|
userId?: number,
|
||||||
|
): Promise<number>;
|
||||||
|
async uploadOrStoreReplyFiles(
|
||||||
|
forumId: number,
|
||||||
|
postId: number,
|
||||||
|
files: CoreFileEntry[],
|
||||||
offline: boolean,
|
offline: boolean,
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
userId?: number,
|
userId?: number,
|
||||||
): Promise<any> {
|
): Promise<CoreFileUploaderStoreFilesResult | number> {
|
||||||
if (offline) {
|
if (offline) {
|
||||||
return this.storeReplyFiles(forumId, postId, files, siteId, userId);
|
return this.storeReplyFiles(forumId, postId, files, siteId, userId);
|
||||||
} else {
|
|
||||||
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModForumProvider.COMPONENT, forumId, siteId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModForumProvider.COMPONENT, forumId, siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue