[ADF-3263] added extra options to upload file for upload service (#3546)

This commit is contained in:
Vito
2018-07-03 20:47:27 +01:00
committed by Eugenio Romano
parent a3372c3a68
commit 23403076a9
3 changed files with 41 additions and 2 deletions

View File

@@ -15,6 +15,8 @@
* limitations under the License.
*/
import { AssocChildBody, AssocTargetBody } from 'alfresco-js-api';
export interface FileUploadProgress {
loaded: number;
total: number;
@@ -28,6 +30,10 @@ export interface FileUploadOptions {
parentId?: string;
path?: string;
nodeType?: string;
properties?: any;
association?: any;
secondaryChildren?: AssocChildBody[];
targets?: AssocTargetBody[];
}
export enum FileUploadStatus {

View File

@@ -186,7 +186,7 @@ describe('UploadService', () => {
expect(uploadFileSpy).toHaveBeenCalledWith({
name: 'fake-name',
size: 10
}, undefined, undefined, null, {
}, undefined, undefined, { newVersion: true }, {
renditions: 'doclib',
include: [ 'allowableOperations' ],
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) => {
let emitter = new EventEmitter();

View File

@@ -189,7 +189,7 @@ export class UploadService {
file.file,
file.options.path,
file.options.parentId,
null,
file.options,
opts
);
}