All Known Implementing Classes:
MediaApiClientModule

public interface MediaAPIs
Defines operations for managing WordPress media items through the WordPress REST API.

This interface provides methods for creating, retrieving, and listing WpMedia resources.

Operations support standard WordPress REST API features such as pagination, filtering, sorting, and retrieval contexts.

Media operations typically involve handling binary file uploads together with metadata such as MIME type, filename, captions, descriptions, and attachment information.

Implementations are expected to communicate with the /wp-json/wp/v2/media endpoint or compatible APIs.

  • Method Details

    • create

      WpMedia create(File file, String fileName, String mimeType)
      Creates a new media item.

      Uploads a media file to WordPress using the provided file content and metadata.

      The uploaded file is sent to the WordPress media endpoint and results in the creation of a new WpMedia attachment resource.

      Parameters:
      file - the file to upload; must not be null
      fileName - the filename to associate with the uploaded media item; must not be null
      mimeType - the MIME type of the uploaded file, for example image/png; must not be null
      Returns:
      the created WpMedia
    • delete

      WpMediaDeletionResponse delete(long id)
      Deletes a media item by its unique identifier.
      Parameters:
      id - the ID of the media item to delete
      Returns:
      the media item deletion response
    • get

      WpMedia get(long id, WpContext context)
      Retrieves a media item by its unique identifier using the given context.

      The context determines which fields are included in the response, for example WpContext.VIEW, WpContext.EDIT, or WpContext.EMBED.

      Parameters:
      id - the ID of the media item to retrieve
      context - the retrieval context; may be null, in which case WpContext.VIEW is used
      Returns:
      the matching WpMedia
    • list

      WpPagedResponse<WpMedia> list(WpPagingQuery pageQuery, WpMediaQuery mediaQuery)
      Retrieves a paginated list of media items using optional filtering and sorting criteria.

      The result set can be refined using WpMediaQuery, for example by filtering on parent, search term, include or exclude lists, or sort order.

      Parameters:
      pageQuery - the pagination settings, including page number and page size; must not be null
      mediaQuery - additional media query parameters; may be null when no extra filtering is needed
      Returns:
      a paginated response containing WpMedia items
    • update

      WpMedia update(long id, WpMediaUpdateRequest updateRequest)
      Updates an existing media item.

      Updates a media item in WordPress using the provided request payload.

      Parameters:
      id - the ID of the media item to update
      updateRequest - the category update request; must not be null
      Returns:
      the updated WpMedia