Constructs a object implementing the File interface.

If it is necessary to add the file to the file store, it will be added and committed before the O.file() function returns. If the same file is added twice, only one copy will be stored, and it will retain the original filename.

If the requested file cannot be retrieved or added to the file store, an exception will be thrown.

function O.file(file)

If a File is passed as an argument, the exact same object will be returned.

function O.file(fileIdentifier)

If a FileIdentifier is passed as an argument, the File it references will be returned from the file store.

function O.file(binaryData)

A BinaryData object, such as an uploaded or generated file, will be added to the file store, then a File object returned after committing the file to the file store.

You may need to set the filename property of the BinaryData object to give it a sensible filename.

function O.file(digest, fileSize)

Look up a File by digest and optional fileSize.

function O.file(object)

Look up a File by properties on the object passed as an argument. object.digest must be a string, and the optional object.fileSize must be a number.

function O.file(signedUrl)

Pass in a signed URL to efficiently copy files between applications that are co-located on the same hosting cluster. If this is not possible for any reason, an exception will be thrown.

Generate the signed URL on the application that contains the file to be copied with code like:

var signedURL = file.url({
  asFullURL: true,
  authenticationSignatureValidForSeconds: 600

Then transfer this URL to the application to which the file should be copied (perhaps using a message bus), and then pass it to O.file() to copy the file.

The pCopyFilesBetweenApplications privilege is required to copy files between applications.