Set file content-type #552
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Is there any way to set a default content-type for files to be uploaded?
I require this to use AWS S3 pre-signed upload URLs.
I tried this but it has no effect on the PUT request headers.
When I choose e.g. an .SQL file the resultant PUT request does not send any content-type header.
I also tried adding a header to the fileItem's header array but this does not work as per https://github.com/valor-software/ng2-file-upload/blob/development/components/file-upload/file-uploader.class.ts#L341
You can set the allowed mimeType:
this.uploader = new FileUploader({
allowedMimeType: ['application/octet-stream']
});
Thanks for the reply but that is not what I am trying to do. All mime types are allowed. I want to set the file's mime type to octet stream if the file does not have any mime type otherwise detected.
When I override the uploader _xhrTransport with my PR, I can accomplish my goal by setting the content type header on the file if the mime type is blank.
I had a similar problem. Mine was related to computer not recognising the mime type. I added the Content-Type header manually like so:
file.headers = [{name: 'Content-Type', value: mime.getType(this.currentFile.some.name)}];
Worked like a charm.
Hi perrosen, where did you set the mime type at, specifically?