cURL - data binary
- Dominant language
- JavaScript
- Stars
- 953
- Forks
- 164
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I was trying to simulate the curl below with unirest without success:
`curl -u 4cb58534-0bf5-45a4-b009-92cc7b66b0a5:rfspLRFj1MnU -X POST --limit-rate 40000 --header "Content-Type: audio/wav" --header "Transfer-Encoding: chunked" --data-binary @01.wav "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?continuous=true"`
I can get everything done, except for the `--data-binary @01.wav`.
I've tried with the 'attach' method, but this service doesnt accept the file via multipart-form.
(the curl is working fine, I've executed a few times here and I'm getting the correct response)
Any thoughts? Current code below
``` javascript
unirest.post('https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?continuous=true&model=' + language)
.headers({'content-type': 'audio/wav',
'transfer-encoding': 'chunked',
'content-length': fileSizeInBytes,
'authorization': 'Basic NGNiNTg1MzQtMGJmNS00NWE0LWIwMDktOTJjYzdiNjZiMGE1OnJmc3BMUkZqMU1uVQ=='})
.attach('file', './uploads/' + randomName) // Attachment
.as.binary(function (response) {
console.log(response.body);
});
```
Thanks in advance.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the request-building path behind attach and as.binary in the current code, then trace how the client sends request bodies and headers. Compare that behavior with the raw audio request represented by the curl command; done means the WAV payload is accepted by the Watson service and its response is returned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100