Attachments & Media

Attachments:

Media Management:

ICAttachment

The base class for message attachments, exposes elements common to all types of attachments.
Attachments can be present on both incoming and outgoing messages.

Public Methods:

getContentType


Gets the content type of the attachment, such as image/video/location.

  Syntax: String getContentType()

  Return Value: Returns the content type.

setContentType


Set the content type of the attachment.

  Syntax: void setContentType(String contentType)

  Parameters:

ParameterTypeDescription
contentTypeStringThe content type.

toJSON

Returns a new JSONObject instance containing attachment data.

  Syntax: JSONObject toJSON()

  Return Value: A JSONObject representation of the attachment.

ICAudioAttachment

Represents an audio file attachment.

fromJSON

Instantiates a new ICAudioAttachment instance from the supplied JSONObject.

The JSONObject must contain valid audio attachment data.

  Syntax: static ICAudioAttachment fromJSON(JSONObject jsonObj)

  Return Value: A new ICAudioAttachment or null if jsonObj is null.

  Parameters:

ParameterTypeDescription
jsonObjJSONObjectA valid JSONObject instance containing audio attachment data.

getDuration


Returns the audio attachment duration, in seconds.

  Syntax: long getDuration()

  Return Value: The audio attachment duration, in seconds.

setDuration


Sets the audio attachment duration, in seconds.

  Syntax: void setDuration(long duration)

  Parameters:

ParameterTypeDescription
durationintSpecifies the duration in seconds.

ICImageAttachment

Represents an Image attachment.

Return TypeMethod
ICImageAttachment[fromJSON(JSONObject jsonObj)](#section-fromjson-a-image-)
Bitmap[getPreviewImage()](#section-getpreviewimage)
void[setPreviewImage(Bitmap preview)](#section-setpreviewimage)

Instantiates a ICImageAttachment from a JSONObject. The JSONObject must contain valid image attachment data.

  Syntax: static ICImageAttachment fromJSON(JSONObject jsonObj)

  Return Value: A new ICImageAttachment instance, or null if jsonObj is null.

  Parameters:

ParameterTypeDescription
jsonObjJSONObjectA JSONObject containing valid image attachment data.

getPreviewImage


Gets the attachment preview image as a bitmap.

  Syntax: Bitmap getPreviewImage()

  Return Value: A bitmap containing the preview image, or null if there is no preview.

setPreviewImage


Sets the attachment preview image.

  Syntax: void setPreviewImage(Bitmap preview)

  Parameters:

ParameterTypeDescription
previewBitmapA Bitmap object containing the preview image.

ICLocationAttachment

Represents location data that may be attached to a message.

Location data is comprised of latitude and longitude.

Return TypeMethod
ICLocationAttachment[fromJSON(JSONObject jsonObj)](#section-fromjson-a-location-)
double[getLatitude()](#section-getlatitude)
double[getLongitude()](#section-getlongitude)
void[setLatitude(double latitude)](#section-setlatitude)
void[setLongitude(double longitude)](#section-setlongitude)


Returns a new ICLocationAttachment instantiated from data contained within a JSONObject. The JSONObject must contain valid location attachment data.

  Syntax: static ICLocationAttachment fromJSON(JSONObject jsonObj)

  Return Value: A new ICLocationAttachment instance, or null if jsonObj is null.

  Parameters:

ParameterTypeDescription
jsonObjJSONObjectA JSONObject instance containing valid location attachment data.

getLatitude


Gets the latitude value.

  Syntax: double getLatitude()

  Return Value: The latitude value.

getLongitude


Gets the longitude value.

  Syntax: double getLongitude()

  Return Value: The longitude value.

setLatitude


Sets the latitude value.

  Syntax: void setLatitude(double latitude)

  Parameters:

ParameterTypeDescription
latitudedoubleSpecifies the latitude value.

setLongitude


Sets the longitude value.

  Syntax: void setLongitude(double longitude)

  Parameters:

ParameterTypeDescription
longitudedoubleSpecifies the longitude value.

ICMediaAttachment

Base class for message attachments which exposes data common to all types of media file.

Return TypeMethod
String[getMediaId()](#section-getmediaid)
long[getSize()](#section-getsize)
URL[getURL()](#section-geturl)
void[setMediaId(String mediaId)](#section-setmediaid)
void[setSize(long size)](#section-setsize)
void[setURL(URL url)](#section-seturl)

getMediaId


Gets the id of the media attachment hosted within the IMIconnect platform.

  Syntax: String getMediaId()

  Return Value: Returns the id of the media attachment.

getSize


Gets the media file attachment size, in bytes.

  Syntax: long getSize()

  Return Value: Returns the file size of the media attachment, in bytes.

getURL


Returns the attachment URL.

  Syntax: URL getURL()

  Return Value: Returns the attachment URL.

setMediaId


Sets the id of the media attachment.

  Syntax: void setMediaId(String id)

  Parameters:

ParameterTypeDescription
idstringSpecifies the id of the attachment.

setSize


Sets the size of the attachment, in bytes.

  Syntax: void setSize(long size)

  Parameters:

ParameterTypeDescription
sizeintegerSpecifies the size of the attachment, in bytes.

setURL


Sets the URL of the media attachment.

  Syntax: void setURL(URL url)

  Parameters:

ParameterTypeDescription
urlURLSpecifies the URL of the media attachment.

ICVideoAttachment

Represents an attachment that contains video data.

Return TypeMethod
ICVideoAttachment[fromJSON(JSONObject jsonObj)](#section-fromjson-a-video-)
long[getDuration()](#section-getduration-a-video-)
Bitmap[getPreviewImage()](#section-getpreviewimage-a-video-)
void[setDuration(long duration)](#section-setduration-a-video-)
void[setPreviewImage(Bitmap image)](#section-setpreviewimage-a-video-)

Instantiates a ICVideoAttachment from a JSONObject. The JSONObject must contain valid video attachment data.

  Syntax: static ICVideoAttachment fromJSON(JSONObject jsonObj)

  Return Value: A new ICVideoAttachment instance, or null if jsonObj is null.

  Parameters:

ParameterTypeDescription
jsonObjJSONObjectA JSONObject instance containing valid video attachment data.


Gets the duration of the video attachment, in seconds.

  Syntax: long getDuration()

  Return Value: The duration of the video attachment, in seconds.


Gets the video attachment preview image as a bitmap.

  Syntax: Bitmap getPreviewImage()

  Return Value: The video attachment preview image as a bitmap, or null if no preview exists.


Sets the duration of the video attachment, in seconds.

  Syntax: void setDuration(long duration)

  Parameters:

ParameterTypeDescription
durationintSpecifies the duration, in seconds.


Sets the preview image of the video attachment.

  Syntax: void setPreviewImage(Bitmap preview)

  Parameters:

ParameterTypeDescription
previewBitmapSpecifies the preview image for the video attachment.

ICMediaFileManager

Manages the process of uploading and downloading content for media file attachments.

Return TypeMethod
void[downloadFile(java.net.URL url, ICFileDownloadCallback callback](#section-downloadfile)
File[getCachedFile(java.net.URL url)](#section-getcachedfile)
boolean[isFileDownloading(java.net.URL url)](#section-isfiledownloading)
boolean[isFileUploading(File file)](#section-isfileuploading)
void[uploadFile(File file, ICFileUploadCallback callback)](#section-uploadfile)
void[uploadFile(File file, String mimeType, ICFileUploadCallback callback)](#section-uploadfile-a-mimetype-)

downloadFile


Downloads a file from a URL.

Operates asynchronously and notifies the result via [ICFileDownloadCallback](doc:callbacks#section-icfiledownloadcallback)

  Syntax: void downloadFile(URL url, ICFileDownloadCallback callback)

  Parameters:

ParameterTypeDescription
urlURLThe URL of the file to be downloaded.
callbackICFileDownloadCallbackInvoked to report the result of the operation.

getCachedFile


Used to obtain a previously downloaded file from the local file cache.

  Syntax: File getCachedFile(URL url)

  Return Value: A File instance, if the download exists in the cache, otherwise null.

  Parameters:

ParameterTypeDescription
urljava.net.URLThe URL to be checked.

isFileDownloading


Checks if the manager is currently downloading a file for the given URL.

  Syntax: boolean isFileDownloading(java.net.URL url)

  Return Value: True if the file is currently being downloaded.

  Parameters:

ParameterTypeDescription
urljava.net.URLThe URL of the file that will be checked.

isFileUploading


Checks if the manager is currently uploading a file to the IMIconnect platform.

  Syntax: boolean isFileUploading(File file)

  Return Value: True if the file is currently being uploaded.

  Parameters:

ParameterTypeDescription
fileFileThe local file to be checked.

uploadFile


Used to upload a file to the IMIconnect platform.

This method attempts to infer the mime type of the file from the file extension, for more granular control use [uploadFile(File file, String mimeType, ICFileUploadCallback callback)](#section-uploadfile-a-mimetype-)

  Syntax: void uploadFile(File file, ICFileUploadCallback callback)

  Parameters:

ParameterTypeDescription
fileFileThe local file to be uploaded.
callback[ICFileUploadCallback](doc:callbacks#section-icfileuploadcallback)Invoked to report the result of the operation.


Used to upload a file to the IMIconnect platform.

  Syntax: void uploadFile(File file, String mimeType, ICFileUploadCallback callback)

  Parameters:

ParameterTypeDescription
fileFileThe local file to be uploaded.
mimeTypeStringThe mimeType of the file.
callback[ICFileUploadCallback](doc:callbacks#section-icfileuploadcallback)Invoked to report the result of the operation.

Copyright © 2000 - 2021 IMImobile Limited | All Rights Reserved