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

Add support for Stream #296

Merged
merged 3 commits into from Apr 21, 2016

Conversation

@nickuraltsev
Copy link
Member

commented Apr 15, 2016

Fixes #2

@coveralls

This comment has been minimized.

Copy link

commented Apr 15, 2016

Coverage Status

Coverage increased (+0.3%) to 91.716% when pulling d88bc12 on nickuraltsev:stream into 5c58b83 on mzabriskie:master.

@BlakeLucchesi

This comment has been minimized.

Copy link

commented Apr 15, 2016

@nickuraltsev Can you share any additional documentation on what is required to support upload streams on the server side? Also, if I stream data to the server does that mean the response has to be streamed back as well?

Really great job on the PR btw, updated tests and documentation are great!

@mzabriskie mzabriskie merged commit 093593c into axios:master Apr 21, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@wilk

This comment has been minimized.

Copy link

commented May 4, 2016

I didn't understand how this is implemented from axios.
Can I use axios with form-data on Node.js?

This is an example but it's not working:

var FormData = require('form-data'),
      axios = require('axios'),
      fs = require('fs'),
      data = new FormData();

data.append('something', 'something');
data.append('file', fs.createReadStream('myFile.md');

axios.post('http://localhost:12345/api', data, {headers: data.getHeaders()}).then(...).catch(...);

This doesn't send data to the server.
What's wrong with that code?

Thanks in advance,
Wilk

@nickuraltsev

This comment has been minimized.

Copy link
Member Author

commented May 4, 2016

@wilk The code looks good to me. Are you using the latest version of axios?

@wilk

This comment has been minimized.

Copy link

commented May 5, 2016

Uhm, right: I'm using the 0.9.1 version. I think it doesn't support yet that feature, right?

@nickuraltsev

This comment has been minimized.

Copy link
Member Author

commented May 5, 2016

@wilk Right, it was implemented in 0.11.0

@wilk

This comment has been minimized.

Copy link

commented May 6, 2016

@nickuraltsev right, it's working with 0.11.0, thanks ;)

@MikeCheel

This comment has been minimized.

Copy link

commented Feb 9, 2017

I think this is broken again. I am getting Error: write after end

@jeffijoe

This comment has been minimized.

Copy link

commented Feb 11, 2017

How do I specify a file name for the stream upload on the server? Usually when you send a HTML file from the browser, it has a file name which is sent to the server.

@digital-flowers

This comment has been minimized.

Copy link

commented Feb 15, 2017

@jeffijoe i don't think this is an issue when you create form data you can send the filename as another form data value formdata.append("filename",filename)

@jeffijoe

This comment has been minimized.

Copy link

commented Feb 15, 2017

Right but I think for it to be as agnostic as possible you would need to specify it in some way for libraries like busboy to pick it up

@isNeilLin

This comment has been minimized.

Copy link

commented Mar 13, 2017

var FormData = require('form-data');
var axios = require('axios');
var form = new FormData();
form.append('bookid',id);
form.append('classes',classes);
form.append('data',fs.createReadStream(__dirname + `${file}`));
axios.defaults.headers.common = form.getHeaders();
axios.post(`${baseUrl}/outline/create`,form)
.then((response)=>{
	console.log(response.data)
})
.catch(e=>{console.log(e)})

I try to post formdata,but not success because content-length
image

@Thinkscape

This comment has been minimized.

Copy link

commented Aug 27, 2017

Works fine... tested with recent versions:

    const form = new FormData();
    form.append('file', fs.createReadStream(path));
    
    const result = await this.client.post(`some/path`, form, {
       headers: form.getHeaders(),
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.