serviejs / popsicle

Simple HTTP requests for node and the browser
MIT License
246 stars 19 forks source link

Uploading files with filenames containing special characters #110

Closed rustemkk closed 6 years ago

rustemkk commented 6 years ago

Hello, we use popsicle for uploading files like this:

const form = popsicle.form({
  ...someDataAboutFileUploadContext,
  fileInput // uploading file
});

const request = popsicle
  .post({
    url,
    body: form,
    transport: popsicle.createTransport({
      withCredentials: true
    })
  })
  .use(popsicle.plugins.parse('json'));

And it works great, but it fails for files with name containing this characters: , ; " ' (comma, semicolon, double quote, single quote). Can you help me to solve this?

blakeembrey commented 6 years ago

Is this from a browser or node.js? It looks like browser since withCredentials, and in which case what is fileInput?

rustemkk commented 6 years ago

This is from browser, and fileInput is file selected by user. For selecting files we use Dropzone from 'react-dropzone', looks like this :) :

file
blakeembrey commented 6 years ago

If it's browser based I don't think I can do anything to help you and I'm unsure why it would fail. The method just returns a native FormData object so everything is outside of this library. Let me know if your seeing something different to what I'm describing though.

blakeembrey commented 6 years ago

@rustemkk If you do find out what's going on, please post it here! I'd definitely love to hear if you find out what's happening, I've not seen it before but I tend to use this more server-side than in browsers.

rustemkk commented 6 years ago

@blakeembrey So sorry for wasting your time.. Turns up it was backend validation on filename. Thank you!