Editar

Compartilhar via


Work with file column definitions 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 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). 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 will be thrown. Learn to upload files.

The MaxSizeInKB 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:

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.

More information:

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 are not available to the tenant's organizations. Solutions that contain excluded data-types will not 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 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
Work with image column definitions using code