Get a File's Content

Gets the content of a file.

Retrieves the content that is associated with a file based on optional search criteria.

Note: For more information about this command, including descriptions of any path and request parameters, request body schema, response codes and schemas, and payload examples, refer to the online API reference for this command at the following web page:

Get a file's content

URI

https://bartendercloud.com/api/librarian/files/{fileId}/content

Note: The bartendercloud.com domain that is referenced in the URI and in the code example that follows must be replaced with the contents of the DataCenterURI claim that is extracted from your access token. For more information, refer to Extracting the DataCenterURI Claim.

Path Parameters

fileId

Type: String

Specifies the ID of the file. Required.

Query Parameters

versionMajor

Type: Integer <int32>

Specifies the requested major version. Gets the latest version if both major and minor versions are not provided. Also gets the latest version if a major version is not provided and if minor versioning is not enabled in the space, regardless of the minor version value. Optional.

versionMinor

Type: Integer <int32>

Specifies the requested minor version. Required when minor versioning is enabled in the space; otherwise optional.

checksum

Type: String

Specifies the requested checksum. File content is returned only if the requested checksum is different than the current checksum. Optional.

createDateTimeUtc

Type: String <date-time>

Specifies the requested "created date and time" value to use to retrieve a file that has the smallest difference that is less than or equal to the provided value. Optional.

Caution: Do not use both a version parameter and the createdDateTimeUtc parameter in a request.

Example

Request body: None.

Response: System.IO.Stream

Copy
// Get the first (1.0) version of a file.
// Assume that fileId is the ID of the target file.
// Assume that majorVersion is 1 (minorVersion will default to 0).
var client = new HttpClient();
HttpResponseMessage msg = await client.GetAsync($"https://bartendercloud.com/api/librarian/files/{fileId}/content?versionMajor={majorVersion}");

if (msg.IsSuccessStatusCode || msg.StatusCode == HttpStatusCode.NoContent)
{
    return await msg.Content.ReadAsStreamAsync();
}