question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blob/Stream/Buffer request support?

See original GitHub issue

How to request with a binary body directly, I cannot find this in document?

For example:

// node stream
const file = fs.createReadStream('./example.png')
// node buffer
const file = fs.readFileSync('./example.png')
// browser
const file = document.querySelector('input[type=file]').files[0]

request
  .post('/proxy')
  .set('Content-Type', 'application/octet-stream')
  .send(file)
  // attach a blob/stream/buffer directly to request body like node node core http module
  .end()

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
bigman73commented, Jan 4, 2019

Thanks. I couldn’t get attach() to work, and actually ended up using send(), which to my surprise worked fine

The buffer was created with:

const buffer = Buffer.from(base64Data, 'base64'); 
const response = await request
        .post('<URL>')
        .send(buffer)
        .set('SubscriptionKey', '<XYZ>')
        .set('Content-Type', 'application/octet-stream')
        .set('Accept', 'application/json');
0reactions
gap1994commented, Dec 31, 2019

how did you used ‘application/octet-stream’ to uploading?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ladjs/superagent - Blob/Stream/Buffer request support?
How to request with a binary body directly, I cannot find this in document? For example: // node stream const file = fs.createReadStream('....
Read more >
Blob.stream() - Web APIs - MDN Web Docs
The Blob interface's stream() method returns a ReadableStream which upon reading returns the data contained within the Blob.
Read more >
Performance tuning for uploads and downloads with Azure ...
Learn how to tune your uploads and downloads for better performance with Azure Storage client library for .NET.
Read more >
Buffer | Node.js v19.3.0 Documentation
arrayBuffer (); blob.size; blob.slice([start[, end[, type]]]); blob.stream() ... Node.js APIs accept plain Uint8Array s wherever Buffer s are supported as ...
Read more >
Do's and Don'ts for Streaming File Uploads to Azure Blob ...
By using the multipart form-data request you can also support sending ... and BlobClient buffer into memory for uploads CloudBlockBlob blob ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found