interface Asset {
    fields: {
        description?: {
            [key: string]: string;
        };
        file: {
            [key: string]: {
                contentType: string;
                details?: Record<string, any>;
                fileName: string;
                upload?: string;
                uploadFrom?: Record<string, any>;
                url?: string;
            };
        };
        title: {
            [key: string]: string;
        };
    };
    metadata?: MetadataProps;
    sys: EntityMetaSysProps;
    archive(): Promise<Asset>;
    delete(): Promise<void>;
    isArchived(): boolean;
    isDraft(): boolean;
    isPublished(): boolean;
    isUpdated(): boolean;
    processForAllLocales(options?: AssetProcessingForLocale): Promise<Asset>;
    processForLocale(locale: string, Options?: AssetProcessingForLocale): Promise<Asset>;
    publish(): Promise<Asset>;
    toPlainObject(): AssetProps;
    unarchive(): Promise<Asset>;
    unpublish(): Promise<Asset>;
    update(): Promise<Asset>;
}

Hierarchy (view full)

Properties

fields: {
    description?: {
        [key: string]: string;
    };
    file: {
        [key: string]: {
            contentType: string;
            details?: Record<string, any>;
            fileName: string;
            upload?: string;
            uploadFrom?: Record<string, any>;
            url?: string;
        };
    };
    title: {
        [key: string]: string;
    };
}

Type declaration

  • Optionaldescription?: {
        [key: string]: string;
    }

    Description for this asset

    • [key: string]: string
  • file: {
        [key: string]: {
            contentType: string;
            details?: Record<string, any>;
            fileName: string;
            upload?: string;
            uploadFrom?: Record<string, any>;
            url?: string;
        };
    }

    File object for this asset

    • [key: string]: {
          contentType: string;
          details?: Record<string, any>;
          fileName: string;
          upload?: string;
          uploadFrom?: Record<string, any>;
          url?: string;
      }
      • contentType: string
      • Optionaldetails?: Record<string, any>

        Details for the file, depending on file type (example: image size in bytes, etc)

      • fileName: string
      • Optionalupload?: string

        Url where the file is available to be downloaded from, into the Contentful asset system. After the asset is processed this field is gone.

      • OptionaluploadFrom?: Record<string, any>
      • Optionalurl?: string

        Url where the file is available at the Contentful media asset system. This field won't be available until the asset is processed.

  • title: {
        [key: string]: string;
    }

    Title for this asset

    • [key: string]: string
metadata?: MetadataProps

Methods

  • Archives the object

    Returns Promise<Asset>

    Object returned from the server with updated metadata.

  • Deletes this object on the server.

    Returns Promise<void>

    Promise for the deletion. It contains no data, but the Promise error case should be handled.

  • Checks if asset is archived. This means it's not exposed to the Delivery/Preview APIs.

    Returns boolean

  • Checks if the asset is in draft mode. This means it is not published.

    Returns boolean

  • Checks if the asset is published. A published asset might have unpublished changes

    Returns boolean

  • Checks if the asset is updated. This means the asset was previously published but has unpublished changes.

    Returns boolean

  • Triggers asset processing after an upload, for the files uploaded to all locales of an asset.

    Parameters

    • Optionaloptions: AssetProcessingForLocale

      Additional options for processing

    Returns Promise<Asset>

    Object returned from the server with updated metadata.

    If the asset takes too long to process. If this happens, retrieve the asset again, and if the url property is available, then processing has succeeded. If not, your file might be damaged.

  • Triggers asset processing after an upload, for the file uploaded to a specific locale.

    Parameters

    • locale: string

      Locale which processing should be triggered for

    • OptionalOptions: AssetProcessingForLocale

    Returns Promise<Asset>

    Object returned from the server with updated metadata.

    If the asset takes too long to process. If this happens, retrieve the asset again, and if the url property is available, then processing has succeeded. If not, your file might be damaged.

  • Publishes the object

    Returns Promise<Asset>

    Object returned from the server with updated metadata.

  • Unarchives the object

    Returns Promise<Asset>

    Object returned from the server with updated metadata.

  • Unpublishes the object

    Returns Promise<Asset>

    Object returned from the server with updated metadata.

  • Sends an update to the server with any changes made to the object's properties

    Returns Promise<Asset>

    Object returned from the server with updated changes.