Created
March 13, 2018 20:35
-
-
Save npfitz/bbb4eb7d263c581bae06ac91e091791c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'), | |
_ = require('lodash'), | |
fs = require('fs'); | |
var url = 'https://na78.salesforce.com/services/data/v39.0/sobjects/Attachment', | |
token = '00Do0000000Kwd1!ARwAQGh714_EED_D.HqUk_3R2aZaJrEqpeZi2MnHChCWXmU6IxSRs6RN8SBbcX5He_Bt4rUz8EHDo5.ncCioQBd0p_vfmqzm', | |
CRLF = '\r\n'; | |
var sfRequest = request({ | |
method: 'POST', | |
uri: url, | |
headers: { | |
'Authorization': 'Bearer 00Do0000000Kwd1!ARwAQGh714_EED_D.HqUk_3R2aZaJrEqpeZi2MnHChCWXmU6IxSRs6RN8SBbcX5He_Bt4rUz8EHDo5.ncCioQBd0p_vfmqzm' | |
}, | |
formData: { | |
Body: { | |
value: request.get('https://scontent-lga3-1.xx.fbcdn.net/v/t31.0-8/26172294_1641426532570090_5572853299467280679_o.jpg?oh=f47698132d57015b14aa4fd9bc103a5f&oe=5B01621B'), | |
options: { | |
'filename': 'carl.jpg' | |
} | |
}, | |
entity_document: { | |
value: JSON.stringify({ | |
name: "carl.jpg", | |
ParentId: '00Q1N00000YKQWy', | |
Description: 'Test Upload' | |
}), | |
options: { | |
contentType: 'application/json' | |
} | |
} | |
} | |
}, function (error, response, body) { | |
if (error) { | |
return console.error('upload failed:', error); | |
} | |
console.log('Upload successful! Server responded with:', body); | |
}); | |
console.log(sfRequest._form._streams); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment