The file handler

All media files, files that are played or recorded, are stored on cloud.aculab.com. This API provides some simple management tools to access those files. A separate Web Services API provides the ability to upload and download files between your local machine and cloud.aculab.com.

It is important that you also read the section about media files which describes some of the effects of Eventual Consistency.

A file manager object is passed to the main(0) function of your application. It does not have to be created.

class UASFileManagement
exists(filename)

Check whether a file exists.

Required argument:
  • filename

    the name of the file to check. Wildcards are not permitted.

This method is provided to confirm the presence of a file in your online media storage area.

If the file is present, this function will return True; otherwise, it will return False.

Usage example:

if file_man.exists(my_file) is False:
    print(my_file + " does not exist")
delete_file(filename)

Delete a file.

Required argument:
  • filename

    the name of the file to delete. Wildcards are not permitted.

This method is provided to delete a file from your online media storage area.

If successful, this function will return True; if unsuccessful, it will return False.

Usage example:

if file_man.exists(my_file) is True:
    file_man.delete_file(my_file)
rename(current_name, new_name)

Rename and/or move a file.

Required argument:
  • current_name

    the name of the file to rename.

  • new_name

    the new name of the file.

This method is provided to rename a file on your online media storage area.

If successful, this function will return True, otherwise it will return False.

Usage example:

if file_man.exists(my_file) is True:
    file_man.rename(my_file, your_file)
validate(filename, cipher)

Check whether an encrypted file can be decrypted with the credentials supplied and that it has valid content.

When a file is uploaded to your cloud media store, it is checked for compatibility. However, and encrypted file cannot be checked at the time of uploading.

When an application is going to play an encrypted WAV file or send an encrypted TIFF, this function can be used to check the compatibility of the file before placing or answering the call. In other words, first call validate on the file, then place or answer the call, and then play or fax the file.

An encrypted file that has not been validated cannot be played or faxed. The validate function must be called first.

Required argument:
  • filename

    the name of the file to validate.

  • cipher

    A Cipher object that contains the credentials to be used for decrypting the file.

This method is provided to confirm that an encrypted file in your cloud media storage area can be played / faxed using the credentials supplied.

This function will return a ValidateResultType. The possible results are:

VALIDATED

The file is correct.

DECRYPTERROR

The file could not be decrypted.

NOTENCRYPTED

The file is not encrypted.

VALIDATEERROR

An incorrect cipher has been supplied; or, the file is not a compatible WAV or TIFF; or, the file was not encrypted correctly. Please see the logs for a description or the error.

FILENOTFOUND

The file is not found.

OTHER

An unspecified error occurred. Please see the logs.

Usage example:

my_cipher = AESCBCCipher(key="3e139a97574248d43bf01de3521474bf69f32ec2fc00edb866c26dcffff9d0a3",
                         vector="9b0ef243445da908976b7dc9c247c29e")

result = file_man.validate(my_file, my_cipher)
if result != file_man.ValidateResultType.VALIDATED:
    print("File did not validate: result is {0}".format(result))