org.appcelerator.titanium
Class TiBlob

java.lang.Object
  extended by org.appcelerator.kroll.KrollProxy
      extended by org.appcelerator.titanium.TiBlob
All Implemented Interfaces:
Handler.Callback, org.appcelerator.kroll.KrollProxySupport

@Kroll.proxy
public class TiBlob
extends KrollProxy

A Titanium Blob object. A Blob can represent any opaque data or input stream.


Field Summary
static int TYPE_DATA
          Represents a Blob that contains data.
static int TYPE_FILE
          Represents a Blob that contains file data.
static int TYPE_IMAGE
          Represents a Blob that contains image data.
static int TYPE_STRING
          Represents a Blob that contains String data.
 
Method Summary
static TiBlob blobFromData(byte[] data)
          Creates a blob from binary data, with mimeType as "application/octet-stream".
static TiBlob blobFromData(byte[] data, String mimetype)
          Creates a blob from binary data with the specified mimetype.
static TiBlob blobFromFile(TiBaseFile file)
          Creates a blob from a file and sets a mimeType based on the file name.
static TiBlob blobFromFile(TiBaseFile file, String mimeType)
          Creates a blob from a file with the specified mimeType.
static TiBlob blobFromImage(Bitmap image)
          Creates a blob from a bitmap.
static TiBlob blobFromString(String data)
          Creates a new TiBlob object from String data.
 byte[] getBytes()
          Returns the content of blob in form of binary data.
 Object getData()
           
 InputStream getInputStream()
           
 int getType()
           
 
Methods inherited from class org.appcelerator.kroll.KrollProxy
fireEvent, fireSyncEvent, getActivity, getCreationUrl, getKrollObject, getLangConversionTable, getProperties, getProperty, handleCreationArgs, handleCreationDict, handleDefaultValues, hasListeners, hasProperty, release, resolveUrl, setModelListener, setProperty, setPropertyAndFire
 

Field Detail

TYPE_IMAGE

public static final int TYPE_IMAGE
Represents a Blob that contains image data.

See Also:
Constant Field Values

TYPE_FILE

public static final int TYPE_FILE
Represents a Blob that contains file data.

See Also:
Constant Field Values

TYPE_DATA

public static final int TYPE_DATA
Represents a Blob that contains data.

See Also:
Constant Field Values

TYPE_STRING

public static final int TYPE_STRING
Represents a Blob that contains String data.

See Also:
Constant Field Values
Method Detail

blobFromString

public static TiBlob blobFromString(String data)
Creates a new TiBlob object from String data.

Parameters:
data - the data used to create blob.
Returns:
new instance of TiBlob.

blobFromFile

public static TiBlob blobFromFile(TiBaseFile file)
Creates a blob from a file and sets a mimeType based on the file name.

Parameters:
file - the file used to create blob.
Returns:
new instane of TiBlob.

blobFromFile

public static TiBlob blobFromFile(TiBaseFile file,
                                  String mimeType)
Creates a blob from a file with the specified mimeType. If the passed mimeType is null, the mimeType will be determined using the file name.

Parameters:
file - the file used to create blob.
mimeType - the mimeType used to create blob.
Returns:
new instance of TiBlob.

blobFromImage

public static TiBlob blobFromImage(Bitmap image)
Creates a blob from a bitmap.

Parameters:
image - the image used to create blob.
Returns:
new instance of TiBlob.

blobFromData

public static TiBlob blobFromData(byte[] data)
Creates a blob from binary data, with mimeType as "application/octet-stream".

Parameters:
data - data used to create blob.
Returns:
new instance of TiBlob.

blobFromData

public static TiBlob blobFromData(byte[] data,
                                  String mimetype)
Creates a blob from binary data with the specified mimetype. If the passed mimetype is null, "application/octet-stream" will be used instead.

Parameters:
data - binary data used to create blob.
mimetype - mimetype used to create blob.
Returns:
a new instance of TiBlob.

getBytes

public byte[] getBytes()
Returns the content of blob in form of binary data. Exception will be thrown if blob's type is unknown.

Returns:
binary data.

getInputStream

public InputStream getInputStream()
Returns:
An InputStream for reading the data of this blob.

getData

public Object getData()
Returns:
the blob's data.

getType

@Kroll.getProperty
@Kroll.method
public int getType()
Returns:
The type of this Blob.
See Also:
TYPE_DATA, TYPE_FILE, TYPE_IMAGE, TYPE_STRING


Copyright © 2010-2012 Appcelerator, Inc. Licensed under the Apache License 2.0