-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Error while posting buffer form data #1892
Comments
This is similar to #318. However, it is old and closed and I could not fix it. I've tried #318 (comment), but I still have same error. |
I've fixed this using This is probably some temporary and quick solution so this issue should not be closed until it works better. const axios = require('axios')
const FormData = require('form-data')
let avatar = Buffer.from(['00', '01', '03', '04', '05', '06', '07', '08', '09']) // Buffer data of image file
let url = 'https://example.com/' // Some URL
let formData = new FormData()
formData.append('avatar', avatar)
let data = ''
for (var i = 0, len = formData._streams.length; i < len; i++) {
if (typeof formData._streams[i] !== 'function') {
data += formData._streams[i] + '\r\n'
}
}
await axios.post(url, data, { // Await is called inside async function
headers: formData.getHeaders()
}) |
Im having the same issue, but i have to send 3 query parameters along with the request. i did not managed to make it work with your solution. :( |
In fact, it is an issue of package |
Description:
I want to post form data with buffer to URL, but I get error
The "string" argument must be one of type string, Buffer, or ArrayBuffer
.Example:
Error:
Environment:
The text was updated successfully, but these errors were encountered: