GetBinaryData
|
||
Revision history:
Introduced in QPR 8.0
Returns binary data from an object defined in the function call. This function can be used to fetch graphs and embedded data from objects.
Synopsis:
BinaryData GetBinaryData(string sessionId, string objectId, string attribute, string options)
Return Value:
A BinaryData object. The BinaryData object has the following member variables:
• | Content (Byte[]). Actual binary content |
• | FileName (String). This is either the original filename of an uploaded file or an automatically generated version. |
• | MimeType (String). MIME type of the binary content. |
Parameters:
sessionId: String. ID of an authenticated session.
objectId: String. ID of an object from which binary data is fetched.
attribute: String. Supported binary data attributes:
• | PG |
o | graph. Querying this attribute equals to calling GetGraph with the attribute's parameters as the value of the Options parameter. See GetGraph for a list of supported parameters. |
o | embeddeddata. Returns the data embedded in an information item. Note: To check whether an information item is embedded, query the infoitem.embedtype attribute. |
• | SC |
o | graph. Querying this attribute equals to calling GetGraph with the attribute's parameters as the value of the Options parameter. See GetGraph for a list of supported parameters. |
• | Portal |
o | embeddeddata. Returns the data embedded in an embedded attachment. Note that you can use for instance [PO].EmbeddedAttachment to get a list of all embedded attachments in the database. |
options: String. List of comma-separated parameters. Language parameters are available similarly as in the QueryObjects function.
Example Procedure:
ServiceClient client = new ServiceClient("WSHttpBinding_IService");
string sessionId = client.Authenticate("qpr", "demo");
BinaryData embeddedInfoItem = client.GetBinaryData(sessionId, "PG.67890.5343", "embeddeddata", "");
string fileName = embeddedInfoItem.FileName;
FileStream fs = new FileStream(fileName, FileMode.Create);
fs.Write(embeddededInfoItem.Content, 0, embeddedInfoItem.Content.Length);
fs.Close();
MessageBox.Show("Downloaded embedded data to file: " + fileName + "\r\nMime type: " + embeddedInfoItem.MimeType);
client.Close();