Compare commits

..

1 Commits

Author SHA1 Message Date
Ken Southerland
088b8de948 Allow additionalParameters to also be null 2021-12-17 14:58:05 -08:00
3 changed files with 1 additions and 19 deletions

View File

@@ -67,7 +67,6 @@ Easy to use Angular2 directives for files upload ([demo](http://valor-software.g
5. `formatDataFunction` - Function to modify the request body. 'DisableMultipart' must be 'true' for this function to be called.
6. `formatDataFunctionIsAsync` - Informs if the function sent in 'formatDataFunction' is asynchronous. Defaults to false.
7. `parametersBeforeFiles` - States if additional parameters should be appended before or after the file. Defaults to false.
8. `queueMaxSizeLimit` - States the maximum allowed size (in bytes) of all files in the queue that are going to be uploaded.
### Events

View File

@@ -30,7 +30,6 @@ export interface FileUploaderOptions {
authToken?: string;
maxFileSize?: number;
queueLimit?: number;
queueMaxSizeLimit? : number;
removeAfterUpload?: boolean;
url: string;
disableMultipart?: boolean;
@@ -80,10 +79,6 @@ export class FileUploader {
this.autoUpload = this.options.autoUpload;
this.options.filters?.unshift({ name: 'queueLimit', fn: this._queueLimitFilter });
if (this.options.queueMaxSizeLimit) {
this.options.filters?.unshift({ name: 'queueMaxSizeLimit', fn: this._queueMaxSizeLimitFilter });
}
if (this.options.maxFileSize) {
this.options.filters?.unshift({ name: 'fileSize', fn: this._fileSizeFilter });
}
@@ -323,7 +318,7 @@ export class FileUploader {
}
// For AWS, Additional Parameters must come BEFORE Files
if (this.options.additionalParameter !== undefined) {
if (this.options.additionalParameter) {
Object.keys(this.options.additionalParameter).forEach((key: string) => {
let paramVal = this.options.additionalParameter?.[ key ];
// Allow an additional parameter to include the filename
@@ -435,17 +430,6 @@ export class FileUploader {
return this.options.queueLimit === undefined || this.queue.length < this.options.queueLimit;
}
protected _queueMaxSizeLimitFilter(item: FileLikeObject): boolean {
let queueFileSize = 0;
let queueNotProcessedItems = this.queue.filter(queuedItem => !(queuedItem.isSuccess || queuedItem.isCancel || queuedItem.isError));
if(queueNotProcessedItems.length>0)
{
// total size of all queued items that are going to be uploaded
queueFileSize = queueNotProcessedItems.map(queuedItem => queuedItem.file.size).reduce((fileSizeA,fileSizeB)=> fileSizeA + fileSizeB);
}
return this.options.queueMaxSizeLimit === undefined || (queueFileSize + item.size) < this.options.queueMaxSizeLimit;
}
protected _isValidFile(file: FileLikeObject, filters: FilterFunction[], options: FileUploaderOptions): boolean {
this._failFilterIndex = -1;

View File

@@ -64,7 +64,6 @@ describe('Directive: FileSelectDirective', () => {
expect(options.isHTML5).toBeTruthy();
expect(options.removeAfterUpload).toBeFalsy();
expect(options.disableMultipart).toBeFalsy();
expect(options.queueMaxSizeLimit).toBeUndefined();
}
});