Replies: 15 comments
-
I'm actually trying to get this working as well. It doesn't seem as if the jsforce Chatter module allows for multipart requests. |
Beta Was this translation helpful? Give feedback.
-
Attaching a new attachment is not implemented right now. If you already have an attachment, you can access the attachment by following code
Planing to implement the attachment features as well as chatter in future release. |
Beta Was this translation helpful? Give feedback.
-
Hi , |
Beta Was this translation helpful? Give feedback.
-
uploading attachments: 'use strict';
var fileOnServer = '/home/ubuntu/myuploaddir/randomfile/randomimage.jpg',
fileName = 'MyRandomImage.jpg',
fileType = 'image/jpeg';
fs.readFile(fileOnServer, function (err, filedata) {
if (err){
console.error(err);
}
else{
var base64data = new Buffer(filedata).toString('base64');
jsForceConn.sobject('Attachment').create({
ParentId: 'mysalesforceContactID',
Name : fileName,
Body: base64data,
ContentType : fileType,
},
function(err, uploadedAttachment) {
console.log(err,uploadedAttachment);
});
}
}); |
Beta Was this translation helpful? Give feedback.
-
Neat, @yawetse ! |
Beta Was this translation helpful? Give feedback.
-
that would be pretty sweet |
Beta Was this translation helpful? Give feedback.
-
Attaching to Chatter would be a great feature. |
Beta Was this translation helpful? Give feedback.
-
Hi @stomita, |
Beta Was this translation helpful? Give feedback.
-
@mvigano can you include a code snippet and your console output? Also are you trying to stream/pipe the file directly from the upload or are you saving the upload to disk first? I've only gotten it to work by saving the uploaded file to disk first and then uploading to Salesforce |
Beta Was this translation helpful? Give feedback.
-
Thank you for your prompt reply, @yawetse !
and right uploading them to SFDC without saving them first to disk... It seems that everything works fine until the file size doesn't exceed 5 MB.... Here is it: step(
function fetchAttachments() {
var group = this.group();
attachments.forEach(function(attach, i) {
logger.debug('Fetching attachment', attach.url);
request(attach.url, group());
});
},
function uploadAttachToSFDC(err, files) {
logger.debug('files:', files);
if (err) { throw err; }
if (files && _.isArray(files) ) {
var group = this.group();
files.forEach(function(file, i) {
if (file.statusCode == 200) {
logger.debug('Attachment ' + attachments[i].url + ' fetched');
// Maximum file size limit to 5 MB
if (parseInt(file.headers["content-length"], 10) < 5000000 ) {
var base64data = new Buffer(file.body).toString('base64');
// Upload attachment to SFDC
conn.sobject('Attachment').create({
ParentId : parentId,
Name: attachments[i].meta.originalName,
Body: base64data,
ContentType: file.headers["content-type"], // attachments[i].meta.mimetype,
//OwnerId: '',
Description: attachments[i].meta.desc
}, group());
} else {
logger.error('File size exceeding 5MB. Attachment NOT uploaded to SFDC');
}
}
});
}
},
... |
Beta Was this translation helpful? Give feedback.
-
@mvigano interesting, I haven't come across that limitation with the way I implemented it in the past. Are there any restrictions on the salesforce side (does your salesforce org have file limit constraints?) Also side note, I've never used step before but async and bluebird (for control flow) worked well for me. It's probably unrelated to the file upload limitation, unless there's some sort of memory constraint i'm unaware of. |
Beta Was this translation helpful? Give feedback.
-
@yawetse , |
Beta Was this translation helpful? Give feedback.
-
What is parentId in upload attachment? |
Beta Was this translation helpful? Give feedback.
-
Please refer to the Salesforce documentation for information about their
API parameters. The ParentId is the record the attachment is being added
to. Your SObject must have notes and attachments enabled.
Check here for more details:
https://help.salesforce.com/articleView?id=loader_attachments.htm&type=0
And search for the API documentation for more technical information.
…On Jun 1, 2017 7:04 AM, "krishan1kamal" ***@***.***> wrote:
What is parentId in upload attachment?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#43 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFNWkS1ipxRSkIFFKIkuamyVuU7jIWreks5r_rbzgaJpZM4CO2aL>
.
|
Beta Was this translation helpful? Give feedback.
-
Hey, guys, I am using Salesforce Mobile SDK (Android) to upload an image. I am using the SDriveTools app which integrates Amazon S3 as a related list. So I uploaded the image to the S3 amazon space using the Amazon SDK (Android), but I have an issue with the SDriveTools app which integrated S3 as related List into the salesforce as mentioned above. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
This thread describes how to download Attachments:
#19
Does anyone have an example that shows how to do an upload?
Beta Was this translation helpful? Give feedback.
All reactions