Public Member Functions | |
__construct ($version, $array="") | |
Create a new SnapExternalFile attached to a version. | |
copy ($newName="") | |
Creates a copy of this file. | |
create ($tmpFile, $originalName, $name="") | |
Creates an actual file on the file system. | |
delete () | |
Destroy this file. | |
getArray () | |
Retrieves "serialized" representation of the file. | |
getName () | |
Retrieves the real name of the file this object represents. | |
getPath () | |
Retrieves path on the server where file is located. | |
getURL () | |
Retrieves URL to file. | |
load ($array) | |
Loads file information from serialized array generated by getArray(). | |
setAcceptable ($fileTypes) | |
For directories: sets which file types are allowed to be contained in the directory. | |
unzip ($callIt) | |
If this is a zipfile, unzips it into a new directory. | |
update ($tmpFile, $originalName, $name="") | |
Modifies existing file or changes its name. | |
weedFiles ($directory= 'default') | |
For directories: weeds out files that do not belong to list of acceptable file types. |
There are several things we may want to do with it.
SnapExternalFile::__construct | ( | $ | version, | |
$ | array = "" | |||
) |
Create a new SnapExternalFile attached to a version.
$version | [SnapVersion]: version that this external file is associated with | |
$array | [array]: array of information representing a file to be loaded (array comes from getArray()) |
SnapExternalFile::copy | ( | $ | newName = "" |
) |
Creates a copy of this file.
The copy can have a different name if given as the sole parameter, otherwise, the old name is used.
$newName | [string]: optional new name for copy |
SnapExternalFile::create | ( | $ | tmpFile, | |
$ | originalName, | |||
$ | name = "" | |||
) |
Creates an actual file on the file system.
Merely creating a SnapExternalFile object is not enough to create a file. You must either call load() to load in an existing file, or call create() to create a new file/directory.
$tmpFile | [string]: path to source file to upload | |
$originalName | [string]: basename of the file (as, e.g., uploaded by the user) | |
$name | [string]: alternate name for the file to be stored for future use |
$tmpFile | [TYPE]: DESCRIPTION | |
$originalName | [TYPE]: DESCRIPTION | |
$name | [TYPE]: DESCRIPTION |
SnapExternalFile::delete | ( | ) |
Destroy this file.
Destroy the file on the filesystem.
SnapExternalFile::getArray | ( | ) |
Retrieves "serialized" representation of the file.
The array returned from here is to be treated as opaque. It can be stored in Snap content, to be used to initialize a SnapExternalFile object in the future.
SnapExternalFile::getName | ( | ) |
Retrieves the real name of the file this object represents.
External files have a hashed named which is meaningless. The original name is stored so that it can be used later after it would otherwise be lost.
SnapExternalFile::getPath | ( | ) |
Retrieves path on the server where file is located.
SnapExternalFile::getURL | ( | ) |
Retrieves URL to file.
SnapExternalFile::load | ( | $ | array | ) |
Loads file information from serialized array generated by getArray().
$array | [array]: representation of the file |
SnapExternalFile::setAcceptable | ( | $ | fileTypes | ) |
For directories: sets which file types are allowed to be contained in the directory.
This is useful for zipfiles, where we want to filter out invalid files in the zip (see weedFiles())
$fileTypes | [array]: list of file suffixes that are acceptable |
SnapExternalFile::unzip | ( | $ | callIt | ) |
If this is a zipfile, unzips it into a new directory.
The new directory is represented by a SnapExternalFile, which is returned from this method. The original zipfile is not deleted.
SnapExternalFile::update | ( | $ | tmpFile, | |
$ | originalName, | |||
$ | name = "" | |||
) |
Modifies existing file or changes its name.
Updating does not create new files, it just changes information about an existing file or changes the file itself, in place.
$tmpFile | [string]: path to source file, or empty string if the file is not to be modified | |
$originalName | [string]: original name of file, if that is to be modified | |
$name | [string]: no idea why we even need this... |
SnapExternalFile::weedFiles | ( | $ | directory = 'default' |
) |
For directories: weeds out files that do not belong to list of acceptable file types.
You can set the list of acceptable files types in setAcceptable().
$directory | [string]: which directory to search for invalid files; defaults to directory represented by this SnapExternalFile object |