balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.84k stars 1.95k forks source link

Uploading non multipart/form-data #7081

Open bagwanpankaj opened 3 years ago

bagwanpankaj commented 3 years ago

Node version: v14.5.0 Sails version (sails): 1.4.0 ORM hook version (sails-hook-orm): 2.1.1 Sockets hook version (sails-hook-sockets): 2.0.0 Organics hook version (sails-hook-organics): NA Grunt hook version (sails-hook-grunt): NA Uploads hook version (sails-hook-uploads): NA DB adapter & version (e.g. sails-mysql@5.55.5): sails-postgresql@1.2.0" Skipper adapter & version (e.g. skipper-s3@5.55.5): NA


We have Sails.JS as backend API server. While getting an attachment with multipart/form-data works smoothly using req.file. But when attachment is sent as binary using Content-Type: application/zip or Content-Type: application/octet-stream POST verb, same is not available as parameter, nor found in request object.

How to get payload in case of application/zip and application/octets-stream content-type

sailsbot commented 3 years ago

@bagwanpankaj Thanks for posting! We'll take a look as soon as possible.

In the mean time, there are a few ways you can help speed things along:

Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.

For help with questions about Sails, click here.

eashaw commented 3 years ago

Hi @bagwanpankaj, I'm not sure what sending a file as binary means, but have you tried sending it that way as content-type: multipart/form-data?

bagwanpankaj commented 3 years ago

We can not leverage content-type: multipart/form-data on tool submitting the data. Only supported content-types are application/zip or application/octets-stream. But I do not find way in Sails.JS to intercept and save attachment sent as application/zip

alxndrsn commented 3 years ago

@bagwanpankaj I imagine if you're really desperate, you could rewrite the Content-Type header in middleware before bodyParser - see middleware.order in https://sailsjs.com/documentation/reference/configuration/sails-config-http.