1

I migrated Angular 13 to Angular 14, and I was forced to update ng2-file-upload library to version 3.0.0

For some reason, I got this error now when uploading a file:

Error: Unexpected value of the `Content-Length` header provided. Expecting either a string or an array, but got: `138`

In the latest version of my Angular app, I had something like this:

import { FileItem } from 'ng2-file-upload';

export class AppFileUploaderDirective extends FileUploader implements OnInit {

  constructor(allowed_extensions?: string) {
    super({ });
    this.setOptions({
      autoUpload: true,
      removeAfterUpload: true,
      filters: allowed_extensions
        ? this.getExtensionFilter(allowed_extensions)
        : [],
    });
  }

}

but now, the library also forced me to provide an URL, so I did something like this:

import { FileItem } from 'ng2-file-upload';

export class AppFileUploaderDirective extends FileUploader implements OnInit {

  constructor(allowed_extensions?: string) {
    super({ url: undefined });
    this.setOptions({
      url: undefined,
      autoUpload: true,
      removeAfterUpload: true,
      filters: allowed_extensions
        ? this.getExtensionFilter(allowed_extensions)
        : [],
    });
  }

}

I dont really know if it has something to do with my error, But i dont know how to proceed. Thanks in advance.

Danilo Bassi
  • 119
  • 1
  • 1
  • 9

1 Answers1

0

I answered your question related to url in below link. ng2-file-upload support Angular 16

url is made mandatory in version 3.0.0 in FileUploaderOptions.

Venkat
  • 1