mrfelna
September 27, 2016, 2:20pm
1
In packages/lib/cdn.cfc, there seems to be two ways to refer to non-public files.
The general consensus seems to be privatefiles:
<cfset setLocation(name="cache",cdn="local",fullpath=normalizePath(application.path.cache),urlpath=normalizePath(application.url.cache)) />
<cfset setLocation(name="images",cdn="local",fullpath=normalizePath(application.path.imageRoot),urlpath=normalizePath(application.url.imageRoot)) />
<cfset setLocation(name="archive",cdn="local",fullpath=normalizePath(application.path.mediaArchive)) />
<cfset setLocation(name="publicfiles",cdn="local",fullpath=normalizePath(application.path.defaultFilePath),urlpath=normalizePath(application.url.fileRoot)) />
<cfset setLocation(name="privatefiles",cdn="local",fullpath=normalizePath(application.path.secureFilePath)) />
<cfset setLocation(name="temp",cdn="local",fullpath=getTempDirectory()) />
However, securefiles are still around:
<cfelseif structkeyexists(stArgs,"dest_localpath")>
<cfset this.cdns[stArgs.source_config.cdn].ioCopyFile(argumentCollection=stArgs) />
<cfelse>
<cfset this.cdns[stArgs.source_config.cdn].ioCopyFile(source_config=stArgs.source_config,source_file=stArgs.source_file,dest_localpath=tmp) />
</cfif>
<!--- DESTINATION can specify a directory or a file --->
<cfif refind("\.\w+$",arguments.existingfile) and not listlast(arguments.existingfile,".") eq listlast(filename,".")>
<cfif len(FORM["#stMetadata.FormFieldPrefix##stMetadata.Name#New"])>
<cfset stResult.value = application.fc.lib.cdn.ioUploadFile(location="publicfiles",destination=arguments.stMetadata.ftDestination,field="#stMetadata.FormFieldPrefix##stMetadata.Name#New",nameconflict="makeunique",uniqueamong="publicfiles,privatefiles") />
</cfif>
Is securefiles legacy?
Nice catch The CDN “location” is indeed called “privatefiles” not “securefiles”.
I’ve fixed these in p720 – two were sample code (used in the docs), the other one in the formtool would have only checked “publicfiles” since the “securefiles” location didn’t exist.
The one place that the string “securefiles” is still used is in the local directory path for the “privatefiles” CDN location (used by cdn/local.cfc, but actually initialised in core/Application.cfc)
<cfset application.path.secureFilePath = "#application.path.project#/securefiles">
1 Like
mrfelna
September 28, 2016, 7:58am
3
Nice!
I found this because using the video formtool causes an error since the location doesn’t exist. The function in question is ioFileExists:
<code>
<cfif application.fc.lib.cdn.ioFileExists(location="cache",file=sCacheFileName)>
<cfreturn sCacheFileName />
</cfif>
</code>
--->
<cffunction name="ioFileExists" returntype="boolean" access="public" output="false" hint="Checks that a specified file exists">
<cfargument name="location" type="string" required="true" />
<cfargument name="file" type="string" required="true" />