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.

Problem to download Document/Attachments

See original GitHub issue

jsforce = require(“jsforce”) conn = new jsforce.Connection({}) conn.login ‘username’, ‘password’, (err, userInfo) -> return console.error(err) if err

# Now you can get the access token and instance URL information.
# Save them to establish connection next time.
console.log "Access Token: "+conn.accessToken
#console.log conn.instanceUrl

# logged in user property
console.log "User ID: " + userInfo.id
console.log "Org ID: " + userInfo.organizationId
fs = require "fs" 
fileOut = fs.createWriteStream('./test.pdf') 
docId = 'documentID' 
conn.sobject('Document').record(docId).blob('Body').pipe(fileOut)

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
stomitacommented, Apr 22, 2014

The code presented here is the right way to download document/attachment blob body to download to Node.js application. If you have error it should be raised in pipe stream.

Try following:

conn.sobject('Document').record(docId).blob('Body').pipe(fileOut)
  .on "error", (err) -> console.error err
0reactions
mayankagarwal900commented, Jan 3, 2020

The code is working fine. but when my attachments in salesforce is very large than how much time will this request will wait.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Email Attachments Won't Download – What to Do - Tech Junkie
This is a very rare occurrence, but sometimes an attachment may be bigger than your storage capacity. If that's the case, computer won't...
Read more >
6 Best Ways to Fix Unable to Download Attachments from Gmail
6 Best Ways to Fix Unable to Download Attachments from Gmail · 1. Update Browser · 2. Disable Antivirus · 3. Clear Browser...
Read more >
Open & download attachments in Gmail - Google Support
Attachments won't open or download · On your computer, check that you're using a supported browser. · Try turning off extensions you have...
Read more >
How to resolve file and attachment download and upload issues
Have trouble with downloading or uploading files or attachments in Shift v8? We've got you covered! Continue reading for 5 quick solutions ...
Read more >
Email Attachments Won't Download - Techwalla
If you received an email with one or more attachments that you can't download to your computer, the most likely culprit is your...
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