Skip to main content

FilesClient

Namespace: Meshmakers.Octo.Sdk.ServiceClient.AssetRepositoryServices.Files

Implementation of IFilesClient over : REST for bytes ({endpoint}/{tenant}/v1/files), the tenant's GraphQL endpoint ({endpoint}/tenants/{tenant}/GraphQL) for metadata.

public sealed class FilesClient : IFilesClient, IDisposable

Inheritance Object → FilesClient
Implements IFilesClient, IDisposable

Remarks:

A plain instead of RestSharp because uploads and downloads must stream (100 MB files) and the problem-details code and the GraphQL extensions.code must reach the caller; the shared GraphQL client of TenantClient drops both. The bearer token is read from the access token object on every request, so a refreshed token is used at once.

Constructors​

FilesClient(IOptions<AssetServiceClientOptions>, IAssetServiceClientAccessToken)​

Constructor for dependency injection.

public FilesClient(IOptions<AssetServiceClientOptions> options, IAssetServiceClientAccessToken accessToken)

Parameters​

options IOptions<AssetServiceClientOptions>
Asset services client options (endpoint and tenant)

accessToken IAssetServiceClientAccessToken
Access token of the asset services client

FilesClient(AssetServiceClientOptions, IServiceClientAccessToken)​

Constructor.

public FilesClient(AssetServiceClientOptions options, IServiceClientAccessToken accessToken)

Parameters​

options AssetServiceClientOptions
Asset services client options (endpoint and tenant)

accessToken IServiceClientAccessToken
Access token

Remarks:

Uses a process-wide over one pooled (connections recycled every five minutes, so DNS changes are picked up), so short-lived clients — the MCP server creates an asset client per tool call — do not open a connection pool each.

FilesClient(AssetServiceClientOptions, IServiceClientAccessToken, HttpMessageHandler, Boolean)​

Constructor with an explicit message handler (custom transports, tests).

public FilesClient(AssetServiceClientOptions options, IServiceClientAccessToken accessToken, HttpMessageHandler handler, bool disposeHandler)

Parameters​

options AssetServiceClientOptions
Asset services client options (endpoint and tenant)

accessToken IServiceClientAccessToken
Access token

handler HttpMessageHandler
HTTP message handler

disposeHandler Boolean
Dispose the handler with the client

Methods​

Dispose()​

public void Dispose()

GetCapabilitiesAsync(CancellationToken)​

public Task<FilesCapabilitiesDto> GetCapabilitiesAsync(CancellationToken cancellationToken)

Parameters​

cancellationToken CancellationToken

Returns​

Task<FilesCapabilitiesDto>

UploadAsync(String, String, Stream, String, FileConflictMode, Boolean, CancellationToken)​

public Task<FileEntryDto> UploadAsync(string root, string path, Stream content, string contentType, FileConflictMode conflict, bool createFolders, CancellationToken cancellationToken)

Parameters​

root String

path String

content Stream

contentType String

conflict FileConflictMode

createFolders Boolean

cancellationToken CancellationToken

Returns​

Task<FileEntryDto>

UploadToFolderAsync(String, String, Stream, String, FileConflictMode, CancellationToken)​

public Task<FileEntryDto> UploadToFolderAsync(string folderRtId, string name, Stream content, string contentType, FileConflictMode conflict, CancellationToken cancellationToken)

Parameters​

folderRtId String

name String

content Stream

contentType String

conflict FileConflictMode

cancellationToken CancellationToken

Returns​

Task<FileEntryDto>

ReplaceContentAsync(String, Stream, String, CancellationToken)​

public Task<FileEntryDto> ReplaceContentAsync(string fileRtId, Stream content, string contentType, CancellationToken cancellationToken)

Parameters​

fileRtId String

content Stream

contentType String

cancellationToken CancellationToken

Returns​

Task<FileEntryDto>

DownloadAsync(String, String, Boolean, CancellationToken)​

public Task<FileDownload> DownloadAsync(string root, string path, bool inline, CancellationToken cancellationToken)

Parameters​

root String

path String

inline Boolean

cancellationToken CancellationToken

Returns​

Task<FileDownload>

DownloadByIdAsync(String, Boolean, CancellationToken)​

public Task<FileDownload> DownloadByIdAsync(string fileRtId, bool inline, CancellationToken cancellationToken)

Parameters​

fileRtId String

inline Boolean

cancellationToken CancellationToken

Returns​

Task<FileDownload>

DownloadZipAsync(ZipRequestDto, CancellationToken)​

public Task<FileDownload> DownloadZipAsync(ZipRequestDto request, CancellationToken cancellationToken)

Parameters​

request ZipRequestDto

cancellationToken CancellationToken

Returns​

Task<FileDownload>

DownloadZipAsync(IEnumerable<String>, String, CancellationToken)​

public Task<FileDownload> DownloadZipAsync(IEnumerable<string> rtIds, string fileName, CancellationToken cancellationToken)

Parameters​

rtIds IEnumerable<String>

fileName String

cancellationToken CancellationToken

Returns​

Task<FileDownload>

GetFolderStatsAsync(String, String, CancellationToken)​

public Task<FolderStatsDto> GetFolderStatsAsync(string root, string path, CancellationToken cancellationToken)

Parameters​

root String

path String

cancellationToken CancellationToken

Returns​

Task<FolderStatsDto>

GetFolderStatsByIdAsync(String, CancellationToken)​

public Task<FolderStatsDto> GetFolderStatsByIdAsync(string folderRtId, CancellationToken cancellationToken)

Parameters​

folderRtId String

cancellationToken CancellationToken

Returns​

Task<FolderStatsDto>

GetLinkedCountsAsync(IEnumerable<String>, CancellationToken)​

public Task<IReadOnlyDictionary<string, int>> GetLinkedCountsAsync(IEnumerable<string> rtIds, CancellationToken cancellationToken)

Parameters​

rtIds IEnumerable<String>

cancellationToken CancellationToken

Returns​

Task<IReadOnlyDictionary<String, Int32>>

ListRootsAsync(Int32, String, CancellationToken)​

public Task<FilesPage> ListRootsAsync(int first, string after, CancellationToken cancellationToken)

Parameters​

first Int32

after String

cancellationToken CancellationToken

Returns​

Task<FilesPage>

GetEntryAsync(String, String, CancellationToken)​

public Task<FileEntryDto> GetEntryAsync(string root, string path, CancellationToken cancellationToken)

Parameters​

root String

path String

cancellationToken CancellationToken

Returns​

Task<FileEntryDto>

GetEntryByIdAsync(String, CancellationToken)​

public Task<FileEntryDto> GetEntryByIdAsync(string rtId, CancellationToken cancellationToken)

Parameters​

rtId String

cancellationToken CancellationToken

Returns​

Task<FileEntryDto>

ListChildrenAsync(String, String, Int32, String, CancellationToken)​

public Task<FilesPage> ListChildrenAsync(string root, string path, int first, string after, CancellationToken cancellationToken)

Parameters​

root String

path String

first Int32

after String

cancellationToken CancellationToken

Returns​

Task<FilesPage>

ListChildrenByIdAsync(String, Int32, String, CancellationToken)​

public Task<FilesPage> ListChildrenByIdAsync(string folderRtId, int first, string after, CancellationToken cancellationToken)

Parameters​

folderRtId String

first Int32

after String

cancellationToken CancellationToken

Returns​

Task<FilesPage>

CreateRootAsync(String, String, CancellationToken)​

public Task<FileEntryDto> CreateRootAsync(string name, string wellKnownName, CancellationToken cancellationToken)

Parameters​

name String

wellKnownName String

cancellationToken CancellationToken

Returns​

Task<FileEntryDto>

CreateFolderAsync(String, String, String, CancellationToken)​

public Task<FileEntryDto> CreateFolderAsync(string root, string parentPath, string name, CancellationToken cancellationToken)

Parameters​

root String

parentPath String

name String

cancellationToken CancellationToken

Returns​

Task<FileEntryDto>

CreateFolderInAsync(String, String, CancellationToken)​

public Task<FileEntryDto> CreateFolderInAsync(string parentRtId, string name, CancellationToken cancellationToken)

Parameters​

parentRtId String

name String

cancellationToken CancellationToken

Returns​

Task<FileEntryDto>

RenameAsync(String, String, CancellationToken)​

public Task RenameAsync(string rtId, string newName, CancellationToken cancellationToken)

Parameters​

rtId String

newName String

cancellationToken CancellationToken

Returns​

Task

MoveAsync(String, String, CancellationToken)​

public Task MoveAsync(string rtId, string targetFolderRtId, CancellationToken cancellationToken)

Parameters​

rtId String

targetFolderRtId String

cancellationToken CancellationToken

Returns​

Task

DeleteAsync(String, CancellationToken)​

public Task DeleteAsync(string rtId, CancellationToken cancellationToken)

Parameters​

rtId String

cancellationToken CancellationToken

Returns​

Task

GetDeleteImpactAsync(String, CancellationToken)​

public Task<DeleteImpactDto> GetDeleteImpactAsync(string rtId, CancellationToken cancellationToken)

Parameters​

rtId String

cancellationToken CancellationToken

Returns​

Task<DeleteImpactDto>

ErrorFromBody(HttpStatusCode, String)​

Maps an error response to FilesApiException: problem details code first, then a code-shaped title, then a fallback derived from the status (e.g. an ingress 413 page).

internal static FilesApiException ErrorFromBody(HttpStatusCode status, string body)

Parameters​

status HttpStatusCode

body String

Returns​

FilesApiException