Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multipart form data? #69

Open
lopezchr opened this issue Sep 4, 2017 · 10 comments
Open

multipart form data? #69

lopezchr opened this issue Sep 4, 2017 · 10 comments
Milestone

Comments

@lopezchr
Copy link

lopezchr commented Sep 4, 2017

I've tryed to use this library to send a multipart form data. I'm using vuejs and javascript FormData but it does not work. I've using axios semantic like this:
https://scotch.io/tutorials/how-to-handle-file-uploads-in-vue-2

var formData = new FormData()
formData.append('fieldName', File)
trae.post(url, formData)

How can I solve this?

@gillchristian
Copy link
Member

gillchristian commented Sep 4, 2017

Hello @lopezchr could you please add the error you get ?

I will take a look

@lopezchr
Copy link
Author

lopezchr commented Sep 5, 2017

The request send an application/json content-type. Now, if I change the content type manually...

    return trae.post(url, formData, {
      headers: {
        Authorization: `Bearer ${token}`
        'Content-Type': 'multipart/form-data'
      }
    })

I had this in my php api.

Missing boundary in multipart/form-data POST data in Unknown on line 0

@HectorNJ
Copy link

HectorNJ commented Sep 13, 2017

try this!

return trae.post(url, formData, {
   headers: {
    Authorization: `Bearer ${token}`
    'Content-Type': ''
  }
})

@thejams
Copy link

thejams commented Jan 17, 2018

did this work ?, i am having a similar problem, only that the trae library does not give me any error but the server does not receive any multipart-form-data

@ndelvalle ndelvalle added this to the 2.0 milestone Mar 25, 2018
@crzurita
Copy link

crzurita commented Apr 6, 2018

I got the same problem. In the docs: // The Headers object associated with the request headers: { 'Content-Type': 'application/json' // Default header for methods with body (patch, post & put) 'X-My-Custom-Header': 'foo-bar' },

I tried override Content-Type: ' ' but doesn't work! I have this response:
content

It seems like still sending with header Content-Type: 'application/json'

@crzurita
Copy link

crzurita commented Apr 6, 2018

I was watching this method:

_initMethodsWithBody() {
    const defaultConf = {
      headers: { 'Content-Type': 'application/json' },
    }
    ;['post', 'put', 'patch'].forEach((method) => {
      this._config.set({ [method]: defaultConf })

      this[method] = (path, body = {}, config = {}) => {
        const url = formatUrl(this._baseUrl, path, config.params)
        const mergedConfig = this._config.merge(config, { body, method, url })

        return this._fetch(url, mergedConfig)
      }
    })
}

I just change:

const defaultConf = { headers: { 'Content-Type': 'application/json' }, }

By this:

const defaultConf = { headers: {}, }

And works because is passing headers: empty by default now.

@cmoralesheras
Copy link

Tengo el mismo problema, no puedo subir imagenes, alguna solucion?

@gillchristian
Copy link
Member

@viciotec looks like @clochi's is right, I will work on it as soon as I can.

@cmoralesheras
Copy link

@viciotec parece que @clochi 's tiene razón, trabajaré en ello tan pronto como pueda.

Ah pasado mucho tiempo y sigue sin solucion

@ndelvalle ndelvalle mentioned this issue Oct 21, 2018
Closed
@gillchristian
Copy link
Member

@cmoralesheras eres bienvenido a colaborar en la librería, nosotros lo hacemos en nuestro tiempo libre

En el momento empezamos a trabajar en la v2 y nos gustaría resolver en issue ahí

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants