|
|
@ -34,6 +34,11 @@ export interface UploadFile extends File { |
|
|
|
description: string; |
|
|
|
description: string; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface UploadResult { |
|
|
|
|
|
|
|
uploads: IPromise<any>[]; |
|
|
|
|
|
|
|
upload: IPromise<any>; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export class OpenProjectFileUploadService { |
|
|
|
export class OpenProjectFileUploadService { |
|
|
|
constructor(protected $q: IQService, |
|
|
|
constructor(protected $q: IQService, |
|
|
|
protected Upload) { |
|
|
|
protected Upload) { |
|
|
@ -42,8 +47,8 @@ export class OpenProjectFileUploadService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Upload multiple files using `ngFileUpload` and return a single promise. |
|
|
|
* Upload multiple files using `ngFileUpload` and return a single promise. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public upload(url: string, files: UploadFile[]): IPromise<any> { |
|
|
|
public upload(url: string, files: UploadFile[]): UploadResult { |
|
|
|
return this.$q.all(_.map(files, (file: UploadFile) => this.Upload.upload({ |
|
|
|
const uploads = _.map(files, (file: UploadFile) => this.Upload.upload({ |
|
|
|
file, url, |
|
|
|
file, url, |
|
|
|
fields: { |
|
|
|
fields: { |
|
|
|
metadata: { |
|
|
|
metadata: { |
|
|
@ -51,7 +56,10 @@ export class OpenProjectFileUploadService { |
|
|
|
fileName: file.name, |
|
|
|
fileName: file.name, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}))); |
|
|
|
})); |
|
|
|
|
|
|
|
const upload = this.$q.all(uploads); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {uploads, upload}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|