public class

ForgeFile

extends Object
java.lang.Object
   ↳ io.trigger.forge.android.core.ForgeFile

Class Overview

Object containing information about a file with methods to access it.

Summary

Public Constructors
ForgeFile(Context context, String path)
Constructor to create a file object referencing a file contained in the src folder of the app
ForgeFile(Context context, JsonElement file)
Constructor to create a file object based on a JavaScript file object.
Public Methods
static AssetFileDescriptor assetForUri(Context context, Uri fileUri)
Take a URI and return the most direct AssetFileDescriptor possible (i.e.
byte[] data()
Access the files data
boolean exists()
AssetFileDescriptor fd()
Used for efficient access to files
String mimeType()
Access the files mime-type (if available)
boolean remove()
Delete the file (if possible)
JsonElement toJSON()
A JSON representation of this file object
String toString()
A string representation of this file object
String url()
Return a String url for the file object, this should work if accessed directly from a WebView.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ForgeFile (Context context, String path)

Constructor to create a file object referencing a file contained in the src folder of the app

Parameters
path path to file relative to src folder

public ForgeFile (Context context, JsonElement file)

Constructor to create a file object based on a JavaScript file object.

Parameters
file JSON file object, must contain a uri property

Public Methods

public static AssetFileDescriptor assetForUri (Context context, Uri fileUri)

Take a URI and return the most direct AssetFileDescriptor possible (i.e. try to avoid creating a cached copy of the file).

public byte[] data ()

Access the files data

Returns
  • The bytes contained in the referenced file
Throws
IOException

public boolean exists ()

Returns
  • Whether the file referenced by this object exists

public AssetFileDescriptor fd ()

Used for efficient access to files

Returns
  • An AssetFileDescriptor for the referenced file

public String mimeType ()

Access the files mime-type (if available)

Returns
  • the files mime-type

public boolean remove ()

Delete the file (if possible)

Returns
  • Whether or not the file was deleted

public JsonElement toJSON ()

A JSON representation of this file object

public String toString ()

A string representation of this file object

public String url ()

Return a String url for the file object, this should work if accessed directly from a WebView.

Returns
  • Url representing this file object.