File columns

Use file columns to store file data up to a specified maximum size. A custom or customizable table can have zero or more file columns. This topic is about working with column definitions in code. To use data stored in these columns, see Use file column data.

Create file columns

The recommended way to create file columns is to use Power Apps and define your columns using the designer. More information: File columns.

Note

A key consideration when creating file columns is the Maximum file size stored in the MaxSizeInKB property. The default setting for this is 32768, or 32 MB. The maximum value is 10485760 KB (10 GB). This value cannot be changed in Power Apps using the designer after you create the file column. You can use the API to update the MaxSizeInKB property. More information: Update a column using Web API and Update a column using SDK

You can also create file columns using the Dataverse SDK for .NET or using the Web API. The following examples show how:

Use the FileAttributeMetadata Class with the CreateAttributeRequest Class to create a file column.

public static void CreateFileColumn(IOrganizationService service, string entityLogicalName, string fileColumnSchemaName) {

    FileAttributeMetadata fileColumn = new()
    {
        SchemaName = fileColumnSchemaName,
        DisplayName = new Label("Sample File Column", 1033),
        RequiredLevel = new AttributeRequiredLevelManagedProperty(
                AttributeRequiredLevel.None),
        Description = new Label("Sample File Column for FileOperation samples", 1033),
        MaxSizeInKB = 30 * 1024 // 30 MB

    };

    CreateAttributeRequest createfileColumnRequest = new() {
        EntityName = entityLogicalName,
        Attribute = fileColumn                   
    };

    service.Execute(createfileColumnRequest);

}

Use the FileAttributeMetadata.MaxSizeInKB property to set the maximum size.

More information:

Block certain types of files

You can control which types of files are not allowed to be saved in file Columns. You can set and change this in the System Settings General tab under the Set blocked file extensions for attachments setting. This setting also applies to files that can be set in the Annotation (note) and Attachment (ActivityMimeAttachment) tables.

You can also query and modify this data programmatically. It is stored in the Organization.BlockedAttachments column. There is only one row in the organization table. You can use the SDK or Web API to query this data:

This function:

protected static string RetrieveBlockedAttachments(IOrganizationService service) {

   var query = new QueryExpression("organization")
   {
         ColumnSet = new ColumnSet("blockedattachments"),
         TopCount = 1
   };
   EntityCollection results = service.RetrieveMultiple(query);
   return (string)results.Entities.FirstOrDefault()["blockedattachments"];

}

Returns a string value like this by default:

ade;adp;app;asa;ashx;asmx;asp;bas;bat;cdx;cer;chm;class;cmd;com;config;cpl;crt;csh;dll;exe;fxp;hlp;hta;htr;htw;ida;idc;idq;inf;ins;isp;its;jar;js;jse;ksh;lnk;mad;maf;mag;mam;maq;mar;mas;mat;mau;mav;maw;mda;mdb;mde;mdt;mdw;mdz;msc;msh;msh1;msh1xml;msh2;msh2xml;mshxml;msi;msp;mst;ops;pcd;pif;prf;prg;printer;pst;reg;rem;scf;scr;sct;shb;shs;shtm;shtml;soap;stm;tmp;url;vb;vbe;vbs;vsmacros;vss;vst;vsw;ws;wsc;wsf;wsh;svg

More information: Build queries with QueryExpression

When anyone tries to upload a file of this type the following error will be thrown:

Name: AttachmentBlocked
Code: 0x80043e09
Number: -2147205623
Message: The attachment is either not a valid type or is too large. It cannot be uploaded or downloaded.

Restrictions with Customer Managed Keys (CMK)

Important

Some restrictions apply when using the File and enhanced Image data-types in Dataverse. If Customer Managed Keys (CMK) is enabled on the tenant, IoT data-types are not available to the tenant's organizations. Solutions that contain excluded data-types will not install. Customers must opt-out of CMK in order to make use of these data-types.

All CMK organizations as of version: 9.2.21052.00103 can support the use of the Dataverse File and Image data-types. Files within CMK organizations are limited to a maximum size of 128MB per file. All files and images within CMK organizations will be stored in the Dataverse relational storage, instead of Dataverse File Blob storage. Other limitations:

  • User Delegation SAS Downloads are not supported
  • Chunking uploads and downloads are limited to a single chunk

See Also

Use file column data
Image columns