Edit

Share via


Work with file column definitions by using code

Use file columns to store file data up to a specified maximum size. File columns are optimized for storing binary data. Dataverse doesn't save this data in the relational data store, which improves performance and reduces the capacity usage. Learn more about storage capacity.

A custom or customizable table can have zero or more file columns. This article 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 by using the designer. For more information, see 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 property is 32768, or 32 MB. The maximum value is 10485760 KB (10 GB). While the API can handle files up to 10 GB in size, the requests must be chunked. The size limit to send a single request is 128 MB. When a client application attempts to send a file larger than 128 MB in a single request, an error is thrown. Learn to upload files.

You can't change the MaxSizeInKB value in Power Apps by using the designer after you create the file column. You can use the API to update the MaxSizeInKB property. For more information, see Update a column using Web API and Update a column using SDK.

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

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.

For more information, see:

Blocked file types

You can control which types of files aren't allowed to be saved in file columns based on the file extension and mime type.

For more information, see:

Restrictions with self-managed key (BYOK)

Important

Some restrictions apply when using the File and full-sized Image data-types in Dataverse. If self-managed key (BYOK) is enabled on the tenant, IoT data-types aren't available to the tenant's organizations. Solutions that contain excluded data-types won't install. Customers must opt out of BYOK in order to make use of these data-types.

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

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

See Also

Use file column data
Work with image column definitions using code