Application Settings


The Attachment module includes the following application settings:
  • ErrorFileNotFound
  • ExtensionsAllowed
  • ExtensionsProhibited
  • FileNameFormatBackwardCompatible
  • ImageCacheDuration
  • ImageExtensions
  • RelativePathFormat
  • Scratchpad
  • SelectByPathEnabled
  • *Template
ErrorFileNotFound (defaults to "The specified file was not found in the '{FileObject}' file object repository.")

This is the error message returned to a user when attempting to retrieve a file from a IFileObject plugin that does not exist. 

ExtensionsAllowed (defaults to '').

This is a comma-delimited list of file name extensions that can be uploaded as attachments. For example, 'pdf, jpg, jpeg, gif, png, bmp' would limit uploaded documents to PDF files and common image formats.

If this setting is empty, the ExtensionsProhibited setting will be considered.

ExtensionsProhibited (defaults to 'exe, hs, bat, msi')

This is a comma-delimited list of file name extensions that will be prohibited. If ExtensionsAllowed is not empty, this setting is ignored.

To allow all file types to be uploaded, set both ExtensionsAllowed and ExtensionsProhibited to empty.

Note: the ExtensionsAllowed and ExtensionsProhibited are enforced server-side, and apply to all attachments. The qbo.Upload behavior supports more targets controls, using an accept option with a comma-delimited list of HTML5 standard mime types.

FileNameFormatBackwardCompatible (defaults to False)

If true, QBO 2.0-style file name formatting is supported. This formatting is deprecated in QBO 3, but remains for backward compatibility.

QBO 2.0 enabled soft-coding an Attachment.PathURL with AttachmentTemplate.FileNameFormat using the C# string.Format() function, using:
  • {0}: Attachment
  • {1}: Object
  • {2}: ObjectID
  • {3}: AttachmentID
  • {4}: a Guid
  • {5}: a
QBO 3 enables easier-to-read encoding of these settings and more, such as:
  • {Attachment}, {Object}, {ObjectID}, {any Attachment field}
  • {Guid}
  • {DateTimeStamp}, {Year}, {Month} and {Day}
  • {Uri.FileName}, {Uri.LocalPath}, {Uri.Host}, {Uri.Extension}

ImageCacheDuration (defaults to 1440, or 1 day)

Number of minutes to tell a browser to cache images for. When invoking Attachment.ashx/View?ID={x}, a MaxAge response header will be added, set to now + ImageCacheDuration minutes. This setting speeds the response time of image-heavy systems like the Valuations module substantially, as users editing forms don't need to re-fetch images on each page draw.

ImageExtensions (defaults to 'jpeg,jpg,bmp,png,gif')

This is a comma-delimited list of file extensions that will be interpreted as images, and thus eligible for re-sizing via the Attachment.Resize() method. Calling Attachment.Resize() on a document with a file name extension not in this list will result in no action being taken (no error will be raised).

RelativePathFormat (defaults to '/{Object}/{ObjectID}/{FileName}')

Defines the default PathURL if not otherwise specified for uploaded attachments.

Scratchpad (defaults to 'c:\Windows\Temp\')

Defines the folder used by the application tier to stream documents for temporary storage. For a web server, scratchpad files are created for upload documents prior to delivery to an IFileObject. For an application server, scratchpad files are used for image re sizing, document generation, and other custom uses.

Use of the Scratchpad setting is encapsulated in the qbo.Attachment.FileObject.CacheStream class, which is a self-deleting FileStream. Thus, unless errors occur during the CacheStream operations, the files created in this folder should automatically be deleted once their are closed.

SelectByPathEnabled (defaults to True)

When true, attachments that are inserted with a FileObjectAssembly and PathURL will be checked against existing Attachment records, and if a match is found, the existing record will be updated instead of an inserted.

*Template (plugin-based defaults)

Each IGenerator plugin may choose to implement a CreateTemplate method, which creates a 'Hello World' template for generation. If this method is implemented, a corresponding application setting should be checked to determine the path to the sample 'Hello World' template.  For the core qbo.Attachment class, the following exist:
  • DelimitedGenerator: 'Samples/DelimitedGenerator.Format.xml'
  • XhtmlGeneratorTemplate: 'Samples/XhtmlGenerator.xslt'
The path is relative to the 'Templates' folder.