{"Name":"Sample.Files.Upload/Download/Compress","ConfigurationID":"12417225-1916-4897-8318-ddb7f775b7ef","searchItems":[],"queryItems":[],"listItems":[],"messageItems":[{"Index":1,"Level":0,"Parameters":{"Value":"Sample of using the file action for a number of purposes.\n1. Uploading a file stores the File in a database table called FileData - you must run the following to create that table:\n\tCREATE TABLE FileData(FileID int identity(1,1),Filename varchar(255), MimeType varchar(255), Data image)\n2. Uploading a file ALSO stores the file in a folder of your site /File.Example/Upload to demonstrate how to store the file\n3. Uploading a file ALSO stores the file in a folder of your site /File.Example/Compressed to demonstrate how to compress a single file from the incoming form variable.\n4. When the Uploaded file is an IMAGE, a scaled image with a width of 64 pixels and a height scaled based on the incoming size ratio is created in /File.Example/Thumbnails\n5. The Files are listed after upload thanks to the query of the FileData table - check the boxes on the left of the filenames and click DOWNLOAD to get a full version of the compressed files.\n\ta. If one file is selected, the returned result is the single uncompressed file (from the database)\n\tb. If more than one file is selected, the download result is a compressed library of all checked files. - A final action deletes the Folder that was created to produce the compressed library.\n"},"ActionType":"Action-Comment","ChildActions":[]},{"Index":2,"Level":0,"Parameters":{"Name":"File List And User Interface","RenderType":"0","skipDebug":"false","includeSearch":"false"},"ActionType":"Action-Region","ChildActions":[{"Index":3,"Level":0,"Parameters":{"Value":"The following layout is fairly simple:\n1. The query returns all the columns, EXCEPT for the Data column which contains the entire value. Don't return a full size column like that unless you really want to send megs of data across the network pipe.\n2. The Header/Footer contain the Upload and Download buttons - basically input box and submit buttons. frmGO is the name of the submit button and it will return UP or DOWN accordingly.\n3. The layout is intended to be used in NON ajax form, because you cannot transfer files via ajax directly."},"ActionType":"Action-Comment","ChildActions":[]},{"Index":4,"Level":0,"Parameters":{"Type":"Query-Query","GroupStatement":"","GroupIndex":"","Value":"Select FileID,FileName,MimeType,DATALENGTH(Data) Size FROM FileData order by fileid","Connection":"","Filter":"","CacheTime":"","CacheName":"","CacheShared":"false"},"ActionType":"Template","ChildActions":[]},{"Index":5,"Level":0,"Parameters":{"Type":"Group-Header","GroupStatement":"","GroupIndex":"","Value":"Upload \n
\n\n\n\t\n\t\n\t\n\t\n\n","Connection":"","Filter":"","CacheTime":"","CacheName":"","CacheShared":"false"},"ActionType":"Template","ChildActions":[{"Index":6,"Level":0,"Parameters":{"Type":"Detail-Detail","GroupStatement":"","GroupIndex":"","Value":"\n\t\n\t\n\t\n\t\n","Connection":"","Filter":"","CacheTime":"","CacheName":"","CacheShared":"false"},"ActionType":"Template","ChildActions":[]}]},{"Index":7,"Level":0,"Parameters":{"Type":"Group-Footer","GroupStatement":"","GroupIndex":"","Value":"\n
NameMime/TypeSize
\n\t\t\n\t[FileName][MimeType][Size]
\n","Connection":"","Filter":"","CacheTime":"","CacheName":"","CacheShared":"false"},"ActionType":"Template","ChildActions":[]},{"Index":8,"Level":0,"Parameters":{"Type":"Detail-NoResults","GroupStatement":"","GroupIndex":"","Value":"Upload \n
\n\n\n\t\n\t\n\t\n\t\n\n\n
NameMime/TypeSize
No files have been uploaded.
","Connection":"","Filter":"","CacheTime":"","CacheName":"","CacheShared":"false"},"ActionType":"Template","ChildActions":[]}]},{"Index":9,"Level":0,"Parameters":{"Name":"Event Handlers - Condition UPLOAD and DOWNLOAD","RenderType":"0","skipDebug":"false","includeSearch":"false"},"ActionType":"Action-Region","ChildActions":[{"Index":10,"Level":0,"Parameters":{"LeftCondition":"'[|frmGo,Form]'","RightCondition":"'UP'","Operator":"=","IsAdvanced":"False"},"ActionType":"Condition-If","ChildActions":[{"Index":11,"Level":0,"Parameters":{"Value":"A few things are happening here:\n1. Inserting the record directly into the database - this is done using a standard Query action and the use of the Hex value of the form field.\n\tOWS supports the ability to convert the file stream directly into HEX (which is the native binary format of SQL), so:\n\ta. frmFile is the name of the form element. It's contents are typically pulled from [frmFile,Form] as expected.\n\tb. [frmFile.Name,Form] gets the Name of the file element.\n\tc. [frmFile.Type,Form] gets the Mime Type of the file element.\n\td. [frmFile.Hex,Form] gets the physical binary data of the file in Hex format.\n\te. [$frmFile:Form,{FILE.IMAGE}] returns True or False depending on whether the file is in fact an image.\n2. The file is inserted into the /File.Example/Upload/ folder under its original file name.\n3. The file is inserted into the /File.Example/Compressed/ folder under its original file name with .zip appended.\n4. If the file is an Image, a thumbnail 64px Wide by the incoming ratio Tall will be created in /File.Example/Thumbnail/ with .thumb.jpg as the extension "},"ActionType":"Action-Comment","ChildActions":[]},{"Index":12,"Level":0,"Parameters":{"Name":"INSERT","Query":"INSERT INTO FileData(Filename,MimeType,Data)\nValues ('[frmFile.Name,Form]','[frmFile.Type,Form]',[frmFile.Hex,Form])","IsProcess":"false","Connection":"","CacheName":"","CacheTime":"","CacheShared":"false"},"ActionType":"Action-Execute","ChildActions":[]},{"Index":13,"Level":0,"Parameters":{"SourceType":"Variable","SourceVariableType":"<Form>","Source":"frmFile","SourceQuery":"","DestinationType":"Path","DestinationVariableType":"","DestinationResponseType":"","SQLFirstRow":"false","ColumnMappings":"","DestinationQuery":"","RunAsProcess":"false","ProcessName":"","Destination":"/File.Example/Upload/[frmFile.Name,Form]","TransformType":"","ImageTransformType":"","ImageFont":"","ImageSize":"","ImageSizeType":"","ImageColor":"","ImageBGColor":"","ImageWidth":"","ImageWidthType":"px","ImageHeight":"","ImageHeightType":"px","ImageQuality":"90","XMLReadPath":"","XMLWritePath":"","FileTask":"compress"},"ActionType":"Action-File","ChildActions":[]},{"Index":14,"Level":0,"Parameters":{"SourceType":"Variable","SourceVariableType":"<Form>","Source":"frmFile","SourceQuery":"","DestinationType":"Path","DestinationVariableType":"","DestinationResponseType":"","SQLFirstRow":"false","ColumnMappings":"","DestinationQuery":"","RunAsProcess":"false","ProcessName":"","Destination":"/File.Example/Compressed/[frmFile.Name,Form].zip","TransformType":"File","ImageTransformType":"","ImageFont":"","ImageSize":"","ImageSizeType":"","ImageColor":"","ImageBGColor":"","ImageWidth":"","ImageWidthType":"px","ImageHeight":"","ImageHeightType":"px","ImageQuality":"90","XMLReadPath":"","XMLWritePath":"","FileTask":"compress"},"ActionType":"Action-File","ChildActions":[]},{"Index":15,"Level":0,"Parameters":{"LeftCondition":"'[COALESCE,\"/File.Example/Upload/[|frmFile.Name,Form]\",Text,{MAPPATH},{FILE.IMAGE}]'","RightCondition":"'True'","Operator":"=","IsAdvanced":"False"},"ActionType":"Condition-If","ChildActions":[{"Index":16,"Level":0,"Parameters":{"SourceType":"Path","SourceVariableType":"<Form>","Source":"/File.Example/Upload/[frmFile.Name,Form]","SourceQuery":"","DestinationType":"Path","DestinationVariableType":"","DestinationResponseType":"","SQLFirstRow":"false","ColumnMappings":"","DestinationQuery":"","RunAsProcess":"false","ProcessName":"","Destination":"/File.Example/Thumbnails/[frmFile.Name,Form].thumb.jpg","TransformType":"Image","ImageTransformType":"Size","ImageFont":"","ImageSize":"","ImageSizeType":"","ImageColor":"","ImageBGColor":"","ImageWidth":"64","ImageWidthType":"px","ImageHeight":"","ImageHeightType":"px","ImageQuality":"90","XMLReadPath":"","XMLWritePath":"","FileTask":"compress"},"ActionType":"Action-File","ChildActions":[]}]}]},{"Index":17,"Level":0,"Parameters":{"LeftCondition":"'[|frmGo,Form]'","RightCondition":"'DOWN'","Operator":"=","IsAdvanced":"False"},"ActionType":"Condition-ElseIf","ChildActions":[{"Index":18,"Level":0,"Parameters":{"Value":"An IF CONDITION is used to check to see if the chkFile value from the form contains a comma \",\". If it does, more than one box was checked and we must compress the result, otherwise only one was present\n\nIf one file is selected, the returned result is the single uncompressed file (from the database). Pay close attention here - to replace the FILENAME,FILE and CONTENTTYPE,FILE from the columns\nin the result, you MUST set the transformation to FILE COPY. That way you can copy the file from the source (SQL) to the Destination (PATH OR RESPONSE). The Data Column is automatically inferred\nas the binary data. Additional columns also control the specific replaced values in those attributes:\n\n1. Filecontent, Content, Image, Source and Data all are processed as the binary data column automatically (when not present, index 0 is used).\n2. Name, Filename are used as the [FILENAME,FILE] value.\n3. ContentType, Mime, Type and MimeType are handled by the [CONTENTTYPE,FILE] value.\n5. Ext, Extension are handled by the [EXTENSION,FILE] value.\n\nIf more than one file is selected, the download result is a compressed library of all checked files. - A final action deletes the Folder that was created to produce the compressed library.\n"},"ActionType":"Action-Comment","ChildActions":[]},{"Index":19,"Level":0,"Parameters":{"LeftCondition":"[$chkFile:Form,{CONTAINS:,}]","RightCondition":"True","Operator":"=","IsAdvanced":"False"},"ActionType":"Condition-If","ChildActions":[{"Index":20,"Level":0,"Parameters":{"Value":"Execute a query and download the files based on the file id (we use [chkFile,Form:number list] \nbecause it checks each value and makes sure it is a number and when it is not a number it throws out the value).\n\nEach resulting record is then transferred down to the file system using the file action."},"ActionType":"Action-Comment","ChildActions":[]},{"Index":21,"Level":0,"Parameters":{"Name":"BATCH","Query":"Select FileID,Filename from FileData where FileID in ([chkFile,Form:number list])","IsProcess":"false","Connection":"","CacheName":"","CacheTime":"","CacheShared":"false"},"ActionType":"Action-Execute","ChildActions":[{"Index":22,"Level":0,"Parameters":{"SourceType":"SQL","SourceVariableType":"<Form>","Source":"","SourceQuery":"--CREATE TABLE FileData(FileID int identity(1,1),Filename varchar(255), MimeType varchar(255), Data image)\n--Filename will automatically Map to the File Action FileName (works for columns FileName or Name)\n--MimeType will automatically Map to the File Action Mime Type (works for columns ContentType, Mime, Type or MimeType)\n--Extension is not present but would map to the file Action Extension column if Ext or Extension is present\n--Data will automatically Map to the File Action Data (works for columns FileContent, Content, Image, Source or Data)\nSelect Data from FileData where FileID = [FileID,BATCH]","DestinationType":"Path","DestinationVariableType":"<Session>","DestinationResponseType":"[CONTENTTYPE,FILE]","SQLFirstRow":"false","ColumnMappings":"","DestinationQuery":"","RunAsProcess":"false","ProcessName":"","Destination":"/File.Example/Download/[UserID,System].[Context.Session.SessionID,System]/[Filename,BATCH]","TransformType":"File","ImageWidth":"","ImageWidthType":"px","ImageHeight":"","ImageHeightType":"px","ImageQuality":"90","XMLReadPath":"","XMLWritePath":"","FileTask":"copy","ImageTransformType":"Size","ImageFont":"","ImageColor":"","ImageBGColor":"","ImageSize":"","ImageSizeType":""},"ActionType":"Action-File","ChildActions":[]}]},{"Index":23,"Level":0,"Parameters":{"SourceType":"Path","SourceVariableType":"","Source":"/File.Example/Download/[UserID,System].[Context.Session.SessionID,System]/**","SourceQuery":"","DestinationType":"Response","DestinationVariableType":"","DestinationResponseType":"application/octet-stream","SQLFirstRow":"false","ColumnMappings":"","DestinationQuery":"","RunAsProcess":"false","ProcessName":"","Destination":"[UserID,System].[Context.Session.SessionID,System].zip","TransformType":"File","ImageTransformType":"","ImageFont":"","ImageSize":"","ImageSizeType":"","ImageColor":"","ImageBGColor":"","ImageWidth":"","ImageWidthType":"px","ImageHeight":"","ImageHeightType":"px","ImageQuality":"90","XMLReadPath":"","XMLWritePath":"","FileTask":"compress"},"ActionType":"Action-File","ChildActions":[]},{"Index":24,"Level":0,"Parameters":{"SourceType":"Path","SourceVariableType":"","Source":"/File.Example/Download/[UserID,System].[Context.Session.SessionID,System]","SourceQuery":"","DestinationType":"","DestinationVariableType":"","DestinationResponseType":"","SQLFirstRow":"false","ColumnMappings":"","DestinationQuery":"","RunAsProcess":"false","ProcessName":"","Destination":"","TransformType":"File","ImageTransformType":"","ImageFont":"","ImageSize":"","ImageSizeType":"","ImageColor":"","ImageBGColor":"","ImageWidth":"","ImageWidthType":"px","ImageHeight":"","ImageHeightType":"px","ImageQuality":"90","XMLReadPath":"","XMLWritePath":"","FileTask":"delete"},"ActionType":"Action-File","ChildActions":[]}]},{"Index":25,"Level":0,"Parameters":{},"ActionType":"Condition-Else","ChildActions":[{"Index":26,"Level":0,"Parameters":{"SourceType":"SQL","SourceVariableType":"","Source":"/File.Example/Download/[UserID,System].[Context.Session.SessionID,System]/**","SourceQuery":"Select * from FileData where FileID = [chkFile,Form:number]","DestinationType":"Response","DestinationVariableType":"","DestinationResponseType":"[CONTENTTYPE,FILE]","SQLFirstRow":"false","ColumnMappings":"","DestinationQuery":"","RunAsProcess":"false","ProcessName":"","Destination":"[FILENAME,FILE]","TransformType":"File","ImageTransformType":"","ImageFont":"","ImageSize":"","ImageSizeType":"","ImageColor":"","ImageBGColor":"","ImageWidth":"","ImageWidthType":"px","ImageHeight":"","ImageHeightType":"px","ImageQuality":"90","XMLReadPath":"","XMLWritePath":"","FileTask":"copy"},"ActionType":"Action-File","ChildActions":[]}]}]},{"Index":27,"Level":0,"Parameters":{"LeftCondition":"'[|frmGo,Form]'","RightCondition":"'DELETE'","Operator":"=","IsAdvanced":"False"},"ActionType":"Condition-ElseIf","ChildActions":[{"Index":28,"Level":0,"Parameters":{"Value":"An IF CONDITION is used to check to see if the chkFile value from the form contains a comma \",\". If it does, more than one box was checked and we must compress the result, otherwise only one was present\n\nIf one file is selected, the returned result is the single uncompressed file (from the database). Pay close attention here - to replace the FILENAME,FILE and CONTENTTYPE,FILE from the columns\nin the result, you MUST set the transformation to FILE COPY. That way you can copy the file from the source (SQL) to the Destination (PATH OR RESPONSE). The Data Column is automatically inferred\nas the binary data. Additional columns also control the specific replaced values in those attributes:\n\n1. Filecontent, Content, Image, Source and Data all are processed as the binary data column automatically (when not present, index 0 is used).\n2. Name, Filename are used as the [FILENAME,FILE] value.\n3. ContentType, Mime, Type and MimeType are handled by the [CONTENTTYPE,FILE] value.\n5. Ext, Extension are handled by the [EXTENSION,FILE] value.\n\nIf more than one file is selected, the download result is a compressed library of all checked files. - A final action deletes the Folder that was created to produce the compressed library.\n"},"ActionType":"Action-Comment","ChildActions":[]},{"Index":29,"Level":0,"Parameters":{"Value":"Execute a query and download the files based on the file id (we use [chkFile,Form:number list] \nbecause it checks each value and makes sure it is a number and when it is not a number it throws out the value).\n\nEach resulting record is then transferred down to the file system using the file action."},"ActionType":"Action-Comment","ChildActions":[]},{"Index":30,"Level":0,"Parameters":{"Name":"BATCH","Query":"--RETURN THE LIST OF FILES FROM THE DATABASE\nSELECT FileID,Filename from FileData where FileID in ([chkFile,Form:number list])\n\n--DELETE THE FILES FROM THE DATABASE NOW\nDELETE from FileData where FileID in ([chkFile,Form:number list])","IsProcess":"false","Connection":"","CacheName":"","CacheTime":"","CacheShared":"false"},"ActionType":"Action-Execute","ChildActions":[{"Index":31,"Level":0,"Parameters":{"SourceType":"Path","SourceVariableType":"<Form>","Source":"/File.Example/Thumbnails/[Filename,BATCH].thumb.jpg","SourceQuery":"Select Data from FileData where FileID = [FileID,BATCH]","DestinationType":"","DestinationVariableType":"<Session>","DestinationResponseType":"[CONTENTTYPE,FILE]","SQLFirstRow":"false","ColumnMappings":"","DestinationQuery":"","RunAsProcess":"false","ProcessName":"","Destination":"","TransformType":"File","ImageWidth":"","ImageWidthType":"px","ImageHeight":"","ImageHeightType":"px","ImageQuality":"90","XMLReadPath":"","XMLWritePath":"","FileTask":"delete","ImageTransformType":"Size","ImageFont":"","ImageColor":"","ImageBGColor":"","ImageSize":"","ImageSizeType":""},"ActionType":"Action-File","ChildActions":[]},{"Index":32,"Level":0,"Parameters":{"SourceType":"Path","SourceVariableType":"<Form>","Source":"/File.Example/Compressed/[Filename,BATCH].zip","SourceQuery":"Select Data from FileData where FileID = [FileID,BATCH]","DestinationType":"","DestinationVariableType":"<Session>","DestinationResponseType":"[CONTENTTYPE,FILE]","SQLFirstRow":"false","ColumnMappings":"","DestinationQuery":"","RunAsProcess":"false","ProcessName":"","Destination":"","TransformType":"File","ImageWidth":"","ImageWidthType":"px","ImageHeight":"","ImageHeightType":"px","ImageQuality":"90","XMLReadPath":"","XMLWritePath":"","FileTask":"delete","ImageTransformType":"Size","ImageFont":"","ImageColor":"","ImageBGColor":"","ImageSize":"","ImageSizeType":""},"ActionType":"Action-File","ChildActions":[]},{"Index":33,"Level":0,"Parameters":{"SourceType":"Path","SourceVariableType":"<Form>","Source":"/File.Example/Upload/[Filename,BATCH]","SourceQuery":"Select Data from FileData where FileID = [FileID,BATCH]","DestinationType":"","DestinationVariableType":"<Session>","DestinationResponseType":"[CONTENTTYPE,FILE]","SQLFirstRow":"false","ColumnMappings":"","DestinationQuery":"","RunAsProcess":"false","ProcessName":"","Destination":"","TransformType":"File","ImageWidth":"","ImageWidthType":"px","ImageHeight":"","ImageHeightType":"px","ImageQuality":"90","XMLReadPath":"","XMLWritePath":"","FileTask":"delete","ImageTransformType":"Size","ImageFont":"","ImageColor":"","ImageBGColor":"","ImageSize":"","ImageSizeType":""},"ActionType":"Action-File","ChildActions":[]}]}]}]}],"recordsPerPage":"0","enableAlphaFilter":"false","enablePageSelection":"false","enableRecordsPerPage":"false","enableCustomPaging":"false","enableExcelExport":false,"enableHide_OnNoQuery":false,"enableHide_OnNoResults":false,"enableAdvancedParsing":true,"enableCompoundIIFConditions":"true","enableQueryDebug":"false","enableQueryDebug_Edit":"false","enableQueryDebug_Admin":"false","enableQueryDebug_Super":"false","enableQueryDebug_Log":false,"enableQueryDebug_ErrorLog":false,"autoRefreshInterval":"","skipRedirectActions":"false","skipSubqueryDebugging":"false","enableAdmin_Edit":true,"enableAdmin_Admin":false,"enableAdmin_Super":false,"BotRecordCount":0,"BotPageVariableName":null,"enableBotShowAllRecords":false,"enableBotDetection":false,"BotNonAjaxText":null,"disableOpenScript":false,"enableSilverlight":false,"enableAJAX":"false","enableAJAXPaging":"false","enableAJAXCustomPaging":"false","enableAJAXCustomStatus":"false","enableAJAXPageHistory":"false","customAJAXPageHistory":"","enableAJAXManual":"false","includeJavascriptUtilities":"false","includeJavascriptValidation":"false","javascriptInclude":[],"javascriptOnComplete":"","enableMultipleColumnSorting":"false","ModuleCommunicationMessageType":"","showAll":"true","useExplicitSystemVariables":"false","enabledForcedQuerySplit":"false","query":"","filter":"","customConnection":"","listItem":"","listAItem":"","defaultItem":"","noqueryItem":"","SearchQuery":"","SearchTitle":"","SearchLink":"","SearchAuthor":"","SearchDate":"","SearchKey":"","SearchContent":"","SearchDescription":"","Header":null,"Footer":null,"Title":null,"Version":"20"}