None |
ioCopyFile()
Copies the specified file between locations.
Note that when copying a file between different CDN types, this function copies the file to the local temporary directory,
then moves it to the target location from there.
Note that while every argument is marked as optional, in practice you need:
- source_location and source_file OR source_localpath
- dest_location and dest_file OR dest_localpath
<cfset application.fc.lib.cdn.ioCopyFile(
source_location="images",
source_file=stLocal.stInstance.thumbnail,
dest_location="archive",
dest_file="/#stLocal.stInstance.typename#/#stLocal.stProps.archiveID#_thumb.#ListLast(stLocal.stInstance.thumbnail,'.')#"
) />
Arguments
Name | Type | Required | Default | Options | Description |
source_location | string | No | | | |
source_file | string | No | | | |
source_localpath | string | No | | | |
dest_location | string | No | | | |
dest_file | string | No | | | |
dest_localpath | string | No | | | |
nameconflict | string | No | overwrite | makeunique,overwrite | |
uniqueamong | string | No | | | If nameconflict=makeunique, then the file is made to be unique among this list of locations |
ioCreateDirectory()
Creates the specified directory, including parent directories.
Arguments
Name | Type | Required | Default | Options | Description |
location | string | Yes | | | |
dir | string | Yes | | | |
ioDeleteFile()
Deletes the specified file.
<cfset application.fc.lib.cdn.ioDeleteFile(location="images",file="/#arguments.stObject[arguments.stMetadata.name]#") />
Arguments
Name | Type | Required | Default | Options | Description |
location | string | Yes | | | |
file | string | Yes | | | |
ioDirectoryExists()
Checks that a specified directory exists
Arguments
Name | Type | Required | Default | Options | Description |
location | string | Yes | | | |
dir | string | Yes | | | |
ioFileExists()
Does what it says on the box. Checks a single location to see if a file exists.
<cfif application.fc.lib.cdn.ioFileExists(location="cache",file=sCacheFileName)>
<cfreturn sCacheFileName />
</cfif>
Arguments
Name | Type | Required | Default | Options | Description |
location | string | Yes | | | |
file | string | Yes | | | |
ioFindFile()
Searches the provided locations, and returns the first that contains the specified file, or an empty string if there isn't any.
<cfset currentLocation = application.fc.lib.cdn.ioFindFile(locations="privatefiles,publicfiles",file=arguments.stObject[arguments.stMetadata.name]) />
Arguments
Name | Type | Required | Default | Options | Description |
locations | string | Yes | | | The returned file will be unique for all the specified locations |
file | string | Yes | | | |
ioGetDirectoryListing()
Returns a query containing the files under the specfied directory. The resulting query has a single field "file", which
is the full path as would be passed into the other CDN functions. The results are recursive and do not include directories,
except by implication.
It is worth noting that the "images" location is unusual in that it usually corresponds to the project WWW directory,
and so a naive query to the "images" location will return everything in the webroot. In practice, listings of "images"
should be filtered by /images.
<cfset qSourceFiles = application.fc.lib.cdn.ioGetDirectoryListing(location=form.source_location,dir=form.source_filter) />
<cfset qTargetFiles = application.fc.lib.cdn.ioGetDirectoryListing(location=form.target_location,dir=form.target_filter) />
<cfset stFound = structnew() />
<cfloop query="qSourceFiles">
<cfif not structkeyexists(stFound,qSourceFiles.file)>
<cfset stFound[qSourceFiles.file] = 1 />
<cfelse>
<cfset stFound[qSourceFiles.file] = stFound[qSourceFiles.file] + 1 />
</cfif>
</cfloop>
<cfloop query="qTargetFiles">
<cfif not structkeyexists(stFound,qTargetFiles.file)>
<cfset stFound[qTargetFiles.file] = 2 />
<cfelse>
<cfset stFound[qTargetFiles.file] = stFound[qTargetFiles.file] + 2 />
</cfif>
</cfloop>
<cfloop collection="#stFound#" item="thisfile">
<cfset queryaddrow(qFiles) />
<cfset querysetcell(qFiles,"file",thisfile) />
<cfset querysetcell(qFiles,"inSource",bitand(stFound[thisfile],1) eq 1) />
<cfset querysetcell(qFiles,"inTarget",bitand(stFound[thisfile],2) eq 2) />
</cfloop>
<cfquery dbtype="query" name="qFiles">select * from qFiles order by file</cfquery>
Arguments
Name | Type | Required | Default | Options | Description |
location | string | Yes | | | |
dir | string | No | | | |
ioGetFileLocation()
Returns serving information for the file - either method=redirect + path=URL OR method=stream + path=local path.
<cfset stImage = application.fc.lib.cdn.ioGetFileLocation(location="images",file=arguments.stMetadata.value) />
<cfoutput><img src="#stImage.path#"></cfoutput>
Arguments
Name | Type | Required | Default | Options | Description |
location | string | Yes | | | |
file | string | Yes | | | |
admin | boolean | No | false | | |
ioGetFileSize()
Returns the size of the file in bytes.
<cfoutput>Size: <span class="image-size">#round(application.fc.lib.cdn.ioGetFileSize(location="images",file=arguments.stMetadata.value)/1024)#</span>KB</cfoutput>
Arguments
Name | Type | Required | Default | Options | Description |
location | string | Yes | | | |
file | string | Yes | | | |
ioGetUniqueFilename()
Returns a version of the specified filename which is unique among every listed location by appending numbers to the name.
Note that it is rare to have to call this function directly, as all functions which put a file into a CDN have options to
enforce filename uniqueness. However if you wish to change how FarCry enforces uniqueness, you can override this function
in your project.
<cfset moveto = ioGetUniqueFilename(locations="privatefiles,publicfiles",file=newfile) />
Arguments
Name | Type | Required | Default | Options | Description |
locations | string | No | | | The returned file will be unique for all the specified locations. If this is not specified, the file will be treated as an absolute local file |
file | string | Yes | | | |
ioMoveFile()
Moves the specified file between locations.
Note that when moving a file between different CDN types, this function moves the file to the local temporary directory,
then to the target location from there.
Note that while every argument is marked as optional, in practice you need:
- source_location and source_file OR source_localpath
- dest_location and dest_file OR dest_localpath
<cfset application.fc.lib.cdn.ioMoveFile(source_location="publicfiles",source_file=arguments.stObject[arguments.stMetadata.name],dest_location="privatefiles") />
Arguments
Name | Type | Required | Default | Options | Description |
source_location | string | No | | | |
source_file | string | No | | | |
source_localpath | string | No | | | |
dest_location | string | No | | | |
dest_file | string | No | | | |
dest_localpath | string | No | | | |
nameconflict | string | No | overwrite | makeunique,overwrite | |
uniqueamong | string | No | | | If nameconflict=makeunique, then the file is made to be unique among this list of locations |
ioReadFile()
Reads from the specified file.
<cfimage action="info" source="#application.fc.lib.cdn.ioReadFile(location='images',file=stResult.value,datatype='image')#" structName="stImage" />
Arguments
Name | Type | Required | Default | Options | Description |
location | string | Yes | | | |
file | string | Yes | | | |
datatype | string | No | text | text,binary,image | |
ioUploadFile()
Uploads the a file to the specified location.
<cfset stResult.value = application.fc.lib.cdn.ioUploadFile(
location="securefiles",
destination=arguments.stMetadata.ftDestination,
field="#stMetadata.FormFieldPrefix##stMetadata.Name#New",
nameconflict="makeunique",
uniqueamong="privatefiles,publicfiles",
acceptedextensions=arguments.stMetadata.ftAllowedFileExtensions
) />
Arguments
Name | Type | Required | Default | Options | Description |
location | string | Yes | | | |
destination | string | Yes | | | |
field | string | Yes | | | |
nameconflict | string | No | overwrite | makeunique,overwrite | |
uniqueamong | string | No | | | If nameconflict=makeunique, then the file is made to be unique among this list of locations |
acceptextensions | string | No | | | |
sizeLimit | numeric | No | | | |
ioWriteFile()
Writes the specified data to a file.
<cfset stResult.filename = application.fc.lib.cdn.ioWriteFile(location="images",file=filename,data=newImage,datatype="image",quality=arguments.quality,nameconflict="makeunique",uniqueamong="images") />
Arguments
Name | Type | Required | Default | Options | Description |
location | string | Yes | | | |
file | string | Yes | | | |
data | any | Yes | | | |
datatype | string | No | text | text,binary,image | |
quality | numeric | No | 1 | | This is only required for image writes |
nameconflict | string | No | overwrite | makeunique,overwrite | |
uniqueamong | string | No | | | If nameconflict=makeunique, then the file is made to be unique among this list of locations |
normalizePath()
Normalizes filename character set, replaces '\' with '/', removes trailing '/'
Arguments
Name | Type | Required | Default | Options | Description |
path | string | Yes | | | |
sanitizeFilename()
Sanitizes filename character set, removing invalid characters
Arguments
Name | Type | Required | Default | Options | Description |
filename | string | Yes | | | |
setLocation()
Sets the specified location
Arguments
Name | Type | Required | Default | Options | Description |
name | string | Yes | | | |
cdn | string | Yes | | | |
locationinfo | struct | No | #structnew()# | | |
validateLocation()
Validates the provided config
Arguments
Name | Type | Required | Default | Options | Description |
locationinfo | struct | No | #structnew()# | | |