Xbasic

a5storage_getitem_as_blob2 Function

Syntax

CR as callResult = a5storage_getItem_as_blob2( c StorageConnectionString, c Itemname[,P presult])

Arguments

connectionStringCharacter

Storage connection string with ::storage:: as a prefix.

itemNameCharacter

The name of the item to fetch.

pResultPointer

An optional dot variable that you can pass in that will be populated with information about the object.

Returns

blob2CR

Returns a value which is a CallResult object. If success, the ReturnDataValue property will have the blob data of the requested item. Properties of interest in the callResult object include: error - .t. or .f., and ReturnDataValue-the blob returned by the function.

Description

This function is a variant of a5storage_getIem_as_blob(), but it returns a CallResult object, with information about whether there was an error when the item was retrieved. The advantage of returning a CallResult is that if there is an error (such as object not found), the callResult object will indicate that there was an error and will show information about the error. If there is no error, the CallResult's ReturnDataValue property will have the blob data. Whereas, when using a5storage_getItem_as_blob(), if the object is not found, an empty blob (blank value) is returned but no further information.

Example

dim cs as c = "mystorageconnection"

dim objname as c = "folder1/obj1.jpg"
dim cr as callResult
dim pResult as p

cr = a5storage_getItem_as_blob2(cs,objname,pResult)

if cr.error = .f. then
    dim blob as b
    if cr.success then
       blob = cr.ReturnDataValue
    else
       'handle the error in some way
       'error text is in the cr.Text
end if

To send the file to the client from an Ajax Callback, see a5Helper_generateFileDownloadJS Function. See also Context.Response.SendFile.

See Also