Table of Contents

Class FileStorageClient

Namespace
Cognite.Simulator.Utils
Assembly
Cognite.Simulator.Utils.dll

HTTP client that can be used to download and upload files from/to a server

public class FileStorageClient
Inheritance
FileStorageClient
Inherited Members

Constructors

FileStorageClient(HttpClient, ILogger<FileStorageClient>)

Initializes this object with the given HTTP client and logger

public FileStorageClient(HttpClient client, ILogger<FileStorageClient> logger)

Parameters

client HttpClient

HTTP client

logger ILogger<FileStorageClient>

logger

Fields

DefaultBufferSize

Default buffer size for file operations (80 KB)

public static readonly int DefaultBufferSize

Field Value

int

LargeFileSize

Maximum file size that can be downloaded without throwing an exception (512 MB)

public static readonly long LargeFileSize

Field Value

long

MaxFileDownloadSize

Maximum file size that can be downloaded (8 GB)

public static readonly long MaxFileDownloadSize

Field Value

long

Methods

DownloadFileAsync(Uri, string, bool)

Downloads the file from the provided uri and saves it in the provided filePath

public Task<bool> DownloadFileAsync(Uri uri, string filePath, bool failLargeFiles = false)

Parameters

uri Uri

URI to download from

filePath string

Path to save the file

failLargeFiles bool

Set to true to throw an exception if the file is larger than LargeFileSize

Returns

Task<bool>

true if success, else false

UploadFileAsync(Uri, StreamContent)

Uploads a file to the provided uri

public Task UploadFileAsync(Uri uri, StreamContent fileStream)

Parameters

uri Uri
fileStream StreamContent

Returns

Task

Exceptions

HttpRequestException