An Orchard Core module (Class Library) that indexes and exports media asset URLs from published content items using YeSQL indexing. Provides an injectable IMediaAssetService and REST API endpoints for querying media assets by content item or content type.
This is a Class Library (Orchard Core module), not a standalone application.
Running
dotnet runwill produce the error "The current OutputType is 'Library'" — this is expected. Orchard Core modules cannot run on their own; they must be referenced by an Orchard Core host application. Usedotnet buildto verify that the module compiles correctly.
- Index media assets from published content items
- Query media assets efficiently using YeSQL LINQ
- REST API endpoints for media asset retrieval
- Support for Azure Storage media references
There are two ways to consume this module in your Orchard Core host application. You can start with the git submodule approach for development and testing, then switch to the NuGet package for production — or use NuGet directly.
Use this approach to consume the live source code without publishing to NuGet. This is ideal while you are actively developing the module alongside your host application.
Inside your Orchard Core host application repository, run:
# Add the submodule into a subfolder (e.g. modules/)
git submodule add https://github.com/eberteogam/MediaAssetExport.git modules/MediaAssetExport
# Initialise and pull the module source
git submodule update --init --recursiveThis creates a modules/MediaAssetExport/ folder containing the full module source and a .gitmodules file that records the reference.
Add a <ProjectReference> to your host application's .csproj:
<ItemGroup>
<ProjectReference Include="modules\MediaAssetExport\MediaAssetExport.csproj" />
</ItemGroup>dotnet build
dotnet runOrchard Core will discover the module automatically. Enable the Media Asset Export feature in the admin panel (Admin → Configuration → Features).
To pull the latest changes from this repository into your host application:
git submodule update --remote modules/MediaAssetExport
git add modules/MediaAssetExport
git commit -m "Update MediaAssetExport submodule"Use this approach once the module has been published to NuGet.org (or when you are ready to stop tracking the source directly).
dotnet add package TeoGamarra.MediaAssetExportOr add the <PackageReference> manually to your host .csproj:
<ItemGroup>
<PackageReference Include="TeoGamarra.MediaAssetExport" Version="1.0.0" />
</ItemGroup>When you are ready to move from tracking live source (submodule) to a versioned NuGet package:
# 1. Remove the submodule
git submodule deinit -f modules/MediaAssetExport
git rm -f modules/MediaAssetExport
rm -rf .git/modules/modules/MediaAssetExport
# 2. Commit the removal
git commit -m "Remove MediaAssetExport submodule"
# 3. Add the NuGet package reference
dotnet add package TeoGamarra.MediaAssetExportThe <ProjectReference> in your .csproj must be replaced with the <PackageReference> above. The API surface (IMediaAssetService, endpoints) is identical in both approaches.
dotnet builddotnet pack --configuration Release
# Package is written to: bin/Release/TeoGamarra.MediaAssetExport.x.y.z.nupkg| Event | Workflow | Result |
|---|---|---|
| Every push / pull request | ci.yml |
Builds + packs; uploads .nupkg as a workflow artifact |
Tag v*.*.* pushed |
release.yml |
Publishes to NuGet.org via NUGET_API_KEY secret |
First run: GitHub requires the repository owner to approve the first workflow run for a new branch or contributor. Go to Actions → CI → (the queued run) → Review pending deployments and click Approve and run.
- Reference or install the package in your Orchard Core host project (see above).
- Enable the Media Asset Export feature in the admin panel (Admin → Configuration → Features).
Inject IMediaAssetService into any service or controller:
// All media URLs from published content items
var allUrls = await _mediaAssetService.GetPublishedMediaAssetsAsync();
// Media URLs for a specific content item
var itemUrls = await _mediaAssetService.GetMediaAssetsByContentItemAsync(contentItemId);
// Media URLs for a specific content type
var typeUrls = await _mediaAssetService.GetMediaAssetsByContentTypeAsync("BlogPost");| Method | Route | Description |
|---|---|---|
| GET | /api/media-assets/published |
All media URLs from published content |
| GET | /api/media-assets/content-item/{contentItemId} |
Media URLs for a specific content item |
| GET | /api/media-assets/content-type/{contentType} |
Media URLs for a specific content type |
No additional configuration is required. The module registers its YeSQL index automatically when the feature is enabled.
Teo Gamarra
MIT