Dynamic File System |
This document describes the dynamic file system in Packflow.
This topic contains the following sections:
Files in packflow are handled via a specific object named PFFile. It it accessible for the user through a PFFIeldFileHolder control in forms, API, or via an embedded WebDAV server. PFFiles are hosted under a parent PFItem
Files are stored in an application-dedicated table, ensuring constant performance even with a growing number of applications. See PFFile for further details about persisted metadata.
Files can be created from a template or uploaded using the FileHolder control. This can be made within an Item's form or via inline editing. File has to be confirmed by saving the parent item, otherwise it won't be persisted after form closing.
Once uploaded, a PFFile can be downloaded, deleted or edited online (MS Office files), even before confirmation.
Each file can be accessed through 2 standardized URLs.
Both URL formats can be used to download files and perform other WebDAV operations.
Operation on file | Required permission on parent item |
---|---|
Create | Update |
Read | Read |
Update | Update |
Delete | Update or Delete |
Here is a list of events developers can hook on to override default behavior.
Here are some exemples on how to use the PFFile object via API.
Subscribe to file events for every file under a ContenType.
Override the item's OnInitialized method, and hook on the events from there. You may also subscribe to events directly on an item instance, but this will have effect on this specific instance only.See following handler and event arguments for further details.
public partial class ParentItemClass:PFItem{ protected override void OnInitialized() { base.OnInitialized(); FileDownloaded += OfficialDocument_FileDownloaded; FileOpened += OfficialDocument_FileDownloaded; BeforeCreateFile += OfficialDocument_BeforeCreateOrUpdateFile; BeforeUpdateFile += OfficialDocument_BeforeCreateOrUpdateFile; } void OfficialDocument_BeforeCreateOrUpdateFile(object sender, PFItem_FileEventArgs e) { //Your event code here. PFFile currentFile = e.File; } }
Get a file from a FileHolder value
Items expose FileHolder fields values as properties returning a PFFieldFileHolderValue object.
public class MyUtils { public List<PFFile> LoadFilesUnderItem(MyItemClass myItemInstance) { PFFieldFileHolderValue fileHolderValue = myItemInstance.__MyFileHolder; //PFFIeldFileHolderValue holds metadata about files in the 'References' collection. //You may find here the file name, its URl, and parents Ids and Guids. PFFileReference fileRef = fileHolderValue.References.FirstOrDefault(); string fileName = fileRef.Name; string fileUrl = fileRef.Url; //You may load files with all metadata and content by using the Files property on the PFItem. List<PFFile> files = myItemInstance.Files.GetByValue(fileHolderValue); return files; } }
Create a file under an item.
public class MyUtils { public void CreateFileUnderItem(MyItemClass myItemInstance) { string fileName = "MyNewFileName.pdf"; byte[] fileContent = File.ReadAllBytes("c:\testFile.pdf"); PFFile newFile = myItemInstance.AttachFile(fileName, fileContent, myItemInstance.ParentContentType.PFField_MyFileHolder); newFile.Save(); //Save parent item to confirm file. myItemInstance.Save(); } }
Do a manual QuickParts dataBinding
Packflow can feed MSOffice documents with Word QuickParts-compatible data. See MS Office integration for further details. The code below loads a PFFile, creates or updates its QuickParts dataset, then saves it.
public class MyUtils { public void RefreshFilesQuickParts(MyItemClass myItemInstance) { PFFile fileToFeed = myItemInstance.Files.GetByValue(myItemInstance__MyFileHolder).FirstOrDefault(); if(fileToFeed!=null && MicaSystems.Utils.Utils_File.IsWord2010File(fileToFeed.Name); { PFQuickPartsBinder binder = new PFQuickPartsBinder(myItemInstance.ParentContentType); Stream updatedFileStream = binder.refreshFile(fileToFeed,myItemInstance); byte[] updatedFileContent = binder.refreshFile2(fileToFeed,myItemInstance); fileToFeed.save(); } } }
See PFQuickPartsBinder for further details.
Note |
---|
Online edition of documents can only be triggered when browsing forms with Internet Explorer or Firefox. Extension to Chrome is scheduled but not yet implemented. |
Note |
---|
Databinding is one-way only, from item's data to document. There is no mechanism to get the values in a document back to the item. This may implemented in custom code, by subscribing to AfterUpdateFile. |
See the following links for further details about XML and Quick Parts in Office.
Office Quick Parts overview Basic description of Quick Parts in MS Word. Well defined Custom XML parts : Content-Types schemasInformation about the XML schemas Packflow complies with for MS Word integration.
Choosing when QuickParts databinding happens for a FileHolder can be set in modeling. There are 3 cumulable options.
HTTP Verb | Supported on file | Supported on folder |
---|---|---|
OPTIONS | Yes | Yes |
PROPFIND | Yes | No |
PROPPATCH | No | No |
GET | Yes | No |
HEAD | Yes | Yes |
LOCK | Yes | No |
UNLOCK | Yes | No |
PUT | Yes | No |
COPY | Yes | No |
DELETE | Yes | No |
When adding the querystring '?Thumb=true' to a WebDAV query, the server will compute a 200px wide png thumbnail and return it if applicable. See GetThumbnail for further details.
Thumbnails are generated for the following file types: