UNPKG

@progress/kendo-angular-upload

Version:

Kendo UI Angular Upload Component

79 lines (78 loc) 2.52 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { PreventableEvent } from './preventable-event'; /** * Arguments for the `upload` event. The `upload` event fires when one or more files are about * to be uploaded. If you cancel the event, the upload is prevented. You can add headers to the request. * * ```ts-no-run * @Component({ * selector: 'my-upload', * template: ` * <kendo-upload * [saveUrl]="uploadSaveUrl" * [removeUrl]="uploadRemoveUrl" * (upload)="uploadEventHandler($event)"> * </kendo-upload> * ` * }) * export class UploadComponent { * uploadSaveUrl = 'saveUrl'; // should represent an actual API endpoint * uploadRemoveUrl = 'removeUrl'; // should represent an actual API endpoint * * uploadEventHandler(e: UploadEvent) { * e.headers = e.headers.append('X-Foo', 'Bar'); * } * } * ``` */ export class UploadEvent extends PreventableEvent { /** * The optional object that is sent to the `upload` handler in the form of key/value pair. * * ```ts-no-run * @Component({ * selector: 'my-upload', * template: ` * <kendo-upload * [saveUrl]="uploadSaveUrl" * [removeUrl]="uploadRemoveUrl" * (upload)="uploadEventHandler($event)"> * </kendo-upload> * ` * }) * export class UploadComponent { * uploadSaveUrl = 'saveUrl'; // should represent an actual API endpoint * uploadRemoveUrl = 'removeUrl'; // should represent an actual API endpoint * * uploadEventHandler(e: UploadEvent) { * e.data = { * description: 'File description' * }; * } * } * ``` */ data; /** * The list of the files that will be uploaded. */ files; /** * The headers of the request. */ headers; /** * @hidden * Constructs the event arguments for the `upload` event. * @param files - The list of the files that will be uploaded. * @param headers - The headers of the request. */ constructor(files, headers) { super(); this.files = files; this.headers = headers; } }