【问题标题】:Remove Content-Disposition and Content-Type from request body using angular-file-upload使用 angular-file-upload 从请求正文中删除 Content-Disposition 和 Content-Type
【发布时间】:2018-03-05 11:17:18
【问题描述】:

我正在使用https://github.com/nervgh/angular-file-upload 进行文件上传。

但是,我看到上传的正文是这样的——

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


------WebKitFormBoundaryXjCfky7muJb4rrZu--

这使得请求大小(Content-Length 标头)大于文件大小。我的服务器需要 fileSize 作为标头,但也需要它与请求正文大小相同。我怎么能 -

a) 告诉 angular-file-upload 只发送正文中的文件,而不添加任何其他数据

b) 如果a) 不可行,请在上传前获取Content_length 标头

【问题讨论】:

  • 那么,您希望没有标头数据,还是希望 content-length 标头包含标头的长度?所以,你实际上并没有连接到 HTTP 服务器,对吧?
  • 我不想要请求正文中的标头数据。如果这不可能,那么我想在上传到服务器之前读取(在 JS 中)内容长度标头,以便我可以根据该更新自定义 fileSize 标头
  • I don't want header data in request body 好吧,它不存在,标题不在正文中,它在标题中

标签: javascript angularjs angular-file-upload


【解决方案1】:

我通过在 fileItem 上设置它来修复它 -

disableMultipart: true

在这个 PR 中关于 angular-file-upload https://github.com/nervgh/angular-file-upload/pull/602 的报道中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    • 1970-01-01
    • 2014-08-22
    • 2017-11-27
    • 2011-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多