Skip to Content

File Directory Manipulation

This article will review working with File Directory Manipulation in Vinyl. Topics covered include moving files between binary and a file system, creating directories from within Vinyl, and binding directories into a File System Panel.

Prerequisites

  • A file system is required to be set up on your Vinyl server (Local, S3, or Network)
    • It is recommended to store the file system DataSourceID on the on the Parameter table for the application you are going to be transferring files from
  • The database you are transferring your files from must be linked to your file system

Columns on a File System File Table

Column Mandatory (Y/N) Data Type Description
DataSourceID(*) Yes UUID The DataSourceID of the file system data source
Name(*) Yes String The name of the file when it is stored in the file system
Directory(*) Yes String The file path of the file being stored in the file system
FullName No String The name of the file when it is stored in the file system
IsDirectory No Boolean Whether or not the file being stored is a folder
Content No Binary The file itself
Extension No String The extension of the file being stored
CreatedOn No Date/Time When the file was inserted into the file system
ModifiedOn No Date/Time When the file was updated in the file system
Length No Integer Length of file in bytes
FolderIcon No Binary The icon of the folder in the file system

Instructions to Move Files from Binary in a Vinyl Table to File System

Folders

  1. If you already have a folder in the file system you wish to store the files in, then you don't need to set up folders through Vinyl
  2. If you want to create a folder in the file system, you'll need so set up Rules in Vinyl to do so:

    • Create an XP CRUD Insert Rule from your applications main database targeting the file table of your file system
      • Keys of the file table that are required to be targeted are DataSourceID (of your file system), Name (Name of the file), and Directory (File Path)
        • DATASOURCEID(*)- If you stored your file system's DataSourceID on your Parameter table, you can build the rule off that table, and use that Parameterized field to target the DataSourceID.
        • NAME(*)- You can use whatever you want as the file/ folder name. It is common practice to not use the actual name of the file and generate a new name when storing in a file system for security reasons.
        • DIRECTORY(*)- If the folder is the highest-level folder in your file system, then use a blank string as the directory. If you are creating a hierarchy of folders, the directory is the file path of the folder, Vinyl automatically assumes the first '\' in the file path.
      • Target the IsDirectory field with a '1' for all folders. This is how Vinyl will know to create a folder in the file system, rather trying to insert it as a file.
      • Register the Insert Rule as an Action on an Event and fire off that Event. If you created a top level folder in your file system, it should appear on the file table of your file system, if the folder/ file is anywhere but the highest tier in your file system, you will have to set up pages to check it inserted correctly, or contact somebody with access to the file system to confirm the folder was created.

Inserting Files into the File System

  1. Create an XP CRUD Insert Rule from the data source and table you are moving the files from targeting the file table of your file system

    • The keys for the file are the same as the folder
      • DATASOURCEID(*)- The DataSourceID of the file system, you can either hardcode the value or cross in the Parameter table if you stored it
      • NAME(*)- It is common practice to not use the original name of the file in your file system, however you may do so. If you don't, make sure you set up a naming convention that is consistent and easy to remember. (Note: If you plan on previewing this file in an embed control, you must concatenate the extension of the file to the end of the name. There is SQL documentation online that will help you trim the extension from the original file name.)
      • DIRECTORY(*)- The path the file will be stored in. A series of folder names separated by '\'.
    • Another field that needs to be targeted for files is Content
      • CONTENT- The file itself. The binary that is being stored on the table

Binding Directories into a File System Panel

  1. When linking to a page using a file system as the panel source, there needs to be binding passed in order to access your files

    • On the object that you are binding from, you must add the fields that you are going to bind on
      • The fields you will bind on are the PK's of the File table in your file system (DataSourceID, Directory, and Name)
    • Wherever you are setting your link to page to the File System page, you must set those fields that you just added to you object as Link Criteria. You can also achieve this between panels if you wish to do it that way.

Example XP CRUD Rule to Create Subfolder

Here is an example XP CRUD Rule which instructs Vinyl to create a subfolder named PaymentImport off of the VinylData folder located on the C: drive. This example assumes the data source path is C:/VinylData.

Rule Configuration:

  • Purpose: XP CRUD
  • Action: Cram
  • Source Data Source: Data source the Rule originates from. Example: InvoicePortal
  • Target Data Source: Data source the Rule is targeting. Example: C Drive
  • Target Layer: Logic Layer
  • Target: Named Table the Rule is targeting. Example: File

Columns Defined in Rule:

  • DataSourceID: 'b24b8338-5c91-4e92-8481-8605944a558d'
  • Directory: *
  • Name: 'PaymentImport'
  • IsDirectory: 1

directoryexample.png

Example XP CRUD Rule to create a subfolder