Skip to main content
Nintex Community Menu Bar

Hi,

 

I created a SmartObject that can upload an image to an image library in SharePoint along with some metadata.  I want to call this SmartObject in code, so I generated a C# class for it via the SmartObject Tester.  I cannot figure out how to pass the image to the "FileObject FileLeafRef" parameter.  I can't find any documentation on this, or code samples.  Can anyone point me in the right direction?

 

public void UploadImage(){      //This is the class generated from the SmO Tester      Production_Image_Archive pia = new Production_Image_Archive();      pia.Machine_x0020_Name = "Apollo301";      pia.Datecode = "UB301151022A";      pia.Footage_x0020_Take_x0020_At = 5268.28;      String filePath = @"C:UsersTest.UserDesktopImageFolderApollo20151021_192614.jpg";      String fileName = "20151021_192614";      FileObject fo = new FileObject("Name", "Value");//not sure what goes here??      Production_Image_Archive_properties imgProp = pia.UploadDocument(pia.Machine_x0020_Name, pia.Datecode, fo);}
do we have any answe on this?

the solution is to convert the file into base64.

 

 

// The path of the image.
string image = @"C:Usersjvasque9Desktopaccounts.jpg";
// ... Read in bytes of image.
byte[] data = File.ReadAllBytes(image);
// ... Convert byte array to Base64 string.
string result = Convert.ToBase64String(data);
// ... Write Base64 string.
Console.WriteLine("ENCODED: " + result);

FileObject fileObject = new FileObject("accounts.jpg",result);

s.AddAttachment(8, fileObject);


Reply