GetFile - AWS CodeCommit

GetFile

Returns the base-64 encoded contents of a specified file and its metadata.

Request Syntax

{ "commitSpecifier": "string", "filePath": "string", "repositoryName": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

commitSpecifier

The fully quaified reference that identifies the commit that contains the file. For example, you can specify a full commit ID, a tag, a branch name, or a reference such as refs/heads/main. If none is provided, the head commit is used.

Type: String

Required: No

filePath

The fully qualified path to the file, including the full name and extension of the file. For example, /examples/file.md is the fully qualified path to a file named file.md in a folder named examples.

Type: String

Required: Yes

repositoryName

The name of the repository that contains the file.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 100.

Pattern: [\w\.-]+

Required: Yes

Response Syntax

{ "blobId": "string", "commitId": "string", "fileContent": blob, "fileMode": "string", "filePath": "string", "fileSize": number }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

blobId

The blob ID of the object that represents the file content.

Type: String

commitId

The full commit ID of the commit that contains the content returned by GetFile.

Type: String

fileContent

The base-64 encoded binary data object that represents the content of the file.

Type: Base64-encoded binary data object

Length Constraints: Maximum length of 6291456.

fileMode

The extrapolated file mode permissions of the blob. Valid values include strings such as EXECUTABLE and not numeric values.

Note

The file mode permissions returned by this API are not the standard file mode permission values, such as 100644, but rather extrapolated values. See the supported return values.

Type: String

Valid Values: EXECUTABLE | NORMAL | SYMLINK

filePath

The fully qualified path to the specified file. Returns the name and extension of the file.

Type: String

fileSize

The size of the contents of the file, in bytes.

Type: Long

Errors

For information about the errors that are common to all actions, see Common Errors.

CommitDoesNotExistException

The specified commit does not exist or no commit was specified, and the specified repository has no default branch.

HTTP Status Code: 400

EncryptionIntegrityChecksFailedException

An encryption integrity check failed.

HTTP Status Code: 500

EncryptionKeyAccessDeniedException

An encryption key could not be accessed.

HTTP Status Code: 400

EncryptionKeyDisabledException

The encryption key is disabled.

HTTP Status Code: 400

EncryptionKeyNotFoundException

No encryption key was found.

HTTP Status Code: 400

EncryptionKeyUnavailableException

The encryption key is not available.

HTTP Status Code: 400

FileDoesNotExistException

The specified file does not exist. Verify that you have used the correct file name, full path, and extension.

HTTP Status Code: 400

FileTooLargeException

The specified file exceeds the file size limit for AWS CodeCommit. For more information about limits in AWS CodeCommit, see Quotas in the AWS CodeCommit User Guide.

HTTP Status Code: 400

InvalidCommitException

The specified commit is not valid.

HTTP Status Code: 400

InvalidPathException

The specified path is not valid.

HTTP Status Code: 400

InvalidRepositoryNameException

A specified repository name is not valid.

Note

This exception occurs only when a specified repository name is not valid. Other exceptions occur when a required repository parameter is missing, or when a specified repository does not exist.

HTTP Status Code: 400

PathRequiredException

The folderPath for a location cannot be null.

HTTP Status Code: 400

RepositoryDoesNotExistException

The specified repository does not exist.

HTTP Status Code: 400

RepositoryNameRequiredException

A repository name is required, but was not specified.

HTTP Status Code: 400

Examples

Example

This example illustrates one usage of GetFile.

Sample Request

POST / HTTP/1.1 Host: codecommit.us-east-1.amazonaws.com Accept-Encoding: identity Content-Length: 124 X-Amz-Target: CodeCommit_20150413.GetFile X-Amz-Date: 20180914T223055Z User-Agent: aws-cli/1.15.9 Python/2.7.11 Darwin/16.7.0 botocore/1.10.9 Content-Type: application/x-amz-json-1.1 Authorization: AWS4-HMAC-SHA256 Credential=AKIAEXAMPLE/20180914/us-east-1/codecommit/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature==8d9b5998EXAMPLE { "commitSpecifier": "main", "repositoryName": "MyDemoRepo", "filePath": "README.md" }

Sample Response

HTTP/1.1 200 OK x-amzn-RequestId: d8ad1d21-EXAMPLE Content-Type: application/x-amz-json-1.1 Content-Length: 2267 Date: Fri, 14 Sep 2018 22:30:56 GMT Connection: keep-alive { "blobId":"559b44fEXAMPLE", "commitId":"c5709475EXAMPLE", "fileContent":"IyBQaHVzEXAMPLE", "filePath":"README.md", "fileSize":1563 "fileMode":"NORMAL" }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: