The forge api namespace supplies some common types which are used by built-in API's and module API's.

Type: File

File objects are simple JavaScript objects which can be serialised using JSON.stringify and safely stored in Forge preferences.

File objects can be obtained in a number of ways:

  • Device Gallery
    • forge.file.getImage
    • forge.file.getImages
    • forge.file.getVideo
    • forge.file.getVideos
  • Device Camera
    • forge.capture.getImage
    • forge.capture.getVideo
  • Remote website
  • forge.file.saveURL
  • forge.file.cacheURL
  • Local filesystem
  • forge.file.getFileFromSourceDirectory


A File object contains the following keys:

    "endpoint": "/tmp",
    "resource": "images/23e4567-e89b-12d3-a456-426614174000.png",
  • endpoint - specifies the endpoint the resource will be served by the built-in webserver.
  • resource - the path to the given resource being served.


  • Files can be converted to an URL that can be referenced by the WebView with the forge.file.getFileFromSourceDirectory API.
  • Files can be uploaded by including them as an array in forge.request.ajax(). For example if myFile1 and myFile2 were images returned by forge.file.getImage():

        url: "http://example.com/file_upload",
        files: [myFile1, myFile2]