简体   繁体   English

使用angular-file-upload从请求正文中删除Content-Disposition和Content-Type

[英]Remove Content-Disposition and Content-Type from request body using angular-file-upload

I'm using https://github.com/nervgh/angular-file-upload for my file uploads. 我正在使用https://github.com/nervgh/angular-file-upload进行文件上传。

However, I see that the upload body is like this - 但是,我看到上传内容是这样的-

------WebKitFormBoundaryXjCfky7muJb4rrZu
Content-Disposition: form-data; name="file"; filename="dump.rdb"
Content-Type: application/octet-stream


------WebKitFormBoundaryXjCfky7muJb4rrZu--

This makes the request size( Content-Length header) more than the file size. 这使得请求大小( Content-Length标头)大于文件大小。 My server needs the fileSize as header, but also needs it to be same as the request body size. 我的服务器需要fileSize作为标头,但也需要与请求正文大小相同。 How can I either - 我怎么能-

a) Tell angular-file-upload to only send file in body, without adding any other data a)告诉angular-file-upload仅在正文中发送文件,而不添加任何其他数据

b) If a) is not possible, Get the Content_length header before upload b)如果a)不可能,请在上传之前获取Content_length标头

I fixed it by setting this on fileItem - 我通过在fileItem上设置它来修复它-

disableMultipart: true

It's covered in this PR on angular-file-upload https://github.com/nervgh/angular-file-upload/pull/602 此PR在angular-file-upload https://github.com/nervgh/angular-file-upload/pull/602上进行了介绍

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM