mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3263] added extra options to upload file for upload service (#3546)
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { AssocChildBody, AssocTargetBody } from 'alfresco-js-api';
|
||||||
|
|
||||||
export interface FileUploadProgress {
|
export interface FileUploadProgress {
|
||||||
loaded: number;
|
loaded: number;
|
||||||
total: number;
|
total: number;
|
||||||
@@ -28,6 +30,10 @@ export interface FileUploadOptions {
|
|||||||
parentId?: string;
|
parentId?: string;
|
||||||
path?: string;
|
path?: string;
|
||||||
nodeType?: string;
|
nodeType?: string;
|
||||||
|
properties?: any;
|
||||||
|
association?: any;
|
||||||
|
secondaryChildren?: AssocChildBody[];
|
||||||
|
targets?: AssocTargetBody[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum FileUploadStatus {
|
export enum FileUploadStatus {
|
||||||
|
@@ -186,7 +186,7 @@ describe('UploadService', () => {
|
|||||||
expect(uploadFileSpy).toHaveBeenCalledWith({
|
expect(uploadFileSpy).toHaveBeenCalledWith({
|
||||||
name: 'fake-name',
|
name: 'fake-name',
|
||||||
size: 10
|
size: 10
|
||||||
}, undefined, undefined, null, {
|
}, undefined, undefined, { newVersion: true }, {
|
||||||
renditions: 'doclib',
|
renditions: 'doclib',
|
||||||
include: [ 'allowableOperations' ],
|
include: [ 'allowableOperations' ],
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
@@ -222,6 +222,39 @@ describe('UploadService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should append to the request the extra upload options', () => {
|
||||||
|
let uploadFileSpy = spyOn(alfrescoApiService.getInstance().upload, 'uploadFile').and.callThrough();
|
||||||
|
let emitter = new EventEmitter();
|
||||||
|
|
||||||
|
let filesFake = new FileModel(
|
||||||
|
<File> { name: 'fake-name', size: 10 },
|
||||||
|
<FileUploadOptions> { parentId: '123', path: 'fake-dir',
|
||||||
|
secondaryChildren: [{ assocType: 'assoc-1', childId: 'child-id' }],
|
||||||
|
association: { assocType: 'fake-assoc' },
|
||||||
|
targets: [{ assocType: 'target-assoc', targetId: 'fake-target-id' }]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
service.addToQueue(filesFake);
|
||||||
|
service.uploadFilesInTheQueue(emitter);
|
||||||
|
|
||||||
|
expect(uploadFileSpy).toHaveBeenCalledWith({
|
||||||
|
name: 'fake-name',
|
||||||
|
size: 10
|
||||||
|
}, 'fake-dir', '123', {
|
||||||
|
newVersion: false,
|
||||||
|
parentId: '123',
|
||||||
|
path: 'fake-dir',
|
||||||
|
secondaryChildren: [
|
||||||
|
{ assocType: 'assoc-1', childId: 'child-id' }],
|
||||||
|
association: { assocType: 'fake-assoc' },
|
||||||
|
targets: [{ assocType: 'target-assoc', targetId: 'fake-target-id' }]
|
||||||
|
}, {
|
||||||
|
renditions: 'doclib',
|
||||||
|
include: ['allowableOperations'],
|
||||||
|
autoRename: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should start downloading the next one if a file of the list is aborted', (done) => {
|
it('should start downloading the next one if a file of the list is aborted', (done) => {
|
||||||
let emitter = new EventEmitter();
|
let emitter = new EventEmitter();
|
||||||
|
|
||||||
|
@@ -189,7 +189,7 @@ export class UploadService {
|
|||||||
file.file,
|
file.file,
|
||||||
file.options.path,
|
file.options.path,
|
||||||
file.options.parentId,
|
file.options.parentId,
|
||||||
null,
|
file.options,
|
||||||
opts
|
opts
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user