📚 SAP Business One SDK Help

GetBlob Method
See Also  Example
pIBlobParams

The database table and its blob field, the key of the record whose blob field is to be retrieved, and the path to the file where the blob field contents are to be saved.

Description

Gets the contents of a blob field in the SAP Business One database.

NOTE: If you want to save a blob field to a file, we recommend that you use the SaveBlobToFile method.

Syntax

Visual Basic
Public Function GetBlob( _
   ByVal pIBlobParams As BlobParams _
) As Blob

Parameters

pIBlobParams

The database table and its blob field, the key of the record whose blob field is to be retrieved, and the path to the file where the blob field contents are to be saved.

Example

Getting contents of a blob field (C#)Copy Code
string blobNewFilePath = @"C:\myblobfile.zip"; 
 
SAPbobsCOM.CompanyService oCompanyService = oCompany.GetCompanyService(); 
 
// Specify a table and blob field 
SAPbobsCOM.BlobParams oBlobParams; 
oBlobParams = (SAPbobsCOM.BlobParams)oCompanyService.GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlobParams); 
oBlobParams.Table = "RDOC"; 
oBlobParams.Field = "Template"; 
 
// Specify key name and key value of a record to update 
SAPbobsCOM.BlobTableKeySegment oKeySegment; 
oKeySegment = oBlobParams.BlobTableKeySegments.Add(); 
oKeySegment.Name = "DocCode"; 
oKeySegment.Value = "ACT10001"; 
 
SAPbobsCOM.Blob oBlob; 
oBlob = (SAPbobsCOM.Blob)oCompanyService.GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlob); 
 
// Get contents of a blob field 
oBlob = oCompanyService.GetBlob(oBlobParams); 
 
// Convert Base64 string to binary 
byte[] buf; 
buf = Convert.FromBase64String(oBlob.Content); 
 
// Write blob file to file system 
FileStream oFile = new FileStream(blobNewFilePath, FileMode.Create, FileAccess.Write); 
oFile.Write(buf, 0, buf.Length); 
oFile.Close(); 
oFile.Dispose();

See Also