Welcome to the new Box Support website. Check out all the details here on what’s changed.

Box for Salesforce createFileFromAttachment with ContentDocument

New post

Comments

4 comments

  • bbfaef

    Almost a year later - is there any way to move a file from Salesforce's Files to Box similar to the createfilefromattachment?

     

    https://developer.box.com/docs/box-for-salesforce-developer-toolkit#section--createfilefromattachment-

     

    We switched to Lightning and all files are now being added as Files instead of Attachments and SF is not part of our content strategy.

    0
    Comment actions Permalink
  • ahardy55

    There is a pretty ugly workaround you can use in Apex. 

     

    ContentVersion cv = [SELECT VersionData, Title, FileExtension FROM ContentVersion WHERE ContentDocumentID = YOUR-CONTENT-DOC];

    Attachment myAttachment  = new Attachment(Name = cv.Title + '.' + cv.fileExtension, Body = cv.VersionData, ParentID = YOUR-PARENT-ID);


    Then you can call the boxtoolkit createFromAttachment, pass in "myAttachment" . No need to actually insert the attachment. 

    Not ideal, but if your users are uploading Files instead of attachments, it's a way around. 

     

     

    0
    Comment actions Permalink
  • LinThaw

    Any other way for ContentDocument file upload with toolkit?

    0
    Comment actions Permalink
  • Accenture Test Team

    Try this:

    ContentVersion cv = [SELECT VersionData, Title, FileExtension FROM ContentVersion WHERE id =: contentVersionId];
    BoxFolderfolder = newBoxFolder(api, folderId);
    BoxFile.InfofileInfo = folder.uploadFile(cv.VersionData, cv.Title + cv.FileExtension);
    0
    Comment actions Permalink

Post is closed for comments.