> For the complete documentation index, see [llms.txt](https://docs.opshub.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.opshub.com/v7.229-1/mbse-connector-sdk-index/mbse-sdk-connector-apis/file-apis/file-get.md).

# Get File

## API Name

API Name: File – Get Content

***

## Overview

This API retrieves the content of a file from the end system.

MBSE Core uses this API to:

* Download file content for attached files
* Retrieve binary file data for synchronization
* Support file transfer between systems
* Stream file content directly without storing intermediate copies

Connector responsibility:

* Receive the `fileLocationUri`.
* Invoke the appropriate mechanism to obtain the file content from `fileLocationUri`.
* Return the content as an `InputStream`.
* Stream the file content.

This API is implemented as a pass-through operation.

***

### API URI

```bash
GET: /mbse/api/1.0/content
    ?projectId={projectId}
    &fileLocationUri={fileLocationUri}
```

***

### URI Parameters

| Name            | Mandatory | Type   | Description                                                 |
| --------------- | --------- | ------ | ----------------------------------------------------------- |
| projectId       | True      | String | ID of the project.                                          |
| fileLocationUri | True      | String | Content download URL or file path where the file is stored. |

***

### Connector Contract

Connector must implement:

```java
void getFileContent(String fileLocationUri)
```

#### Method Behavior

* Accept `fileLocationUri` as input.
* Return the content as `InputStream` in the servlet response.

***

### Behavior Rules

1. `projectId` must be validated before retrieving content.
2. `fileLocationUri` must be present.
3. File content should be streamed directly whenever possible.
4. Avoid loading entire files into memory for large files.
5. If file cannot be found:
   * Return HTTP `404 Not Found`
6. If access is denied:
   * Return HTTP `404 Not Found`
7. If file retrieval fails:
   * Return HTTP `500 Internal Server Error`
8. Connector must close streams appropriately after transfer completion.

***

### Response Payload

#### Success Response

Binary stream response.

Example:

```http
HTTP/1.1 200 OK
Content-Type: application/octet-stream
```

Response body:

```
<binary file content>
```

***

### Response Headers

| Header         | Required | Description                     |
| -------------- | -------- | ------------------------------- |
| Content-Type   | False    | MIME type of file if available. |
| Content-Length | False    | File size in bytes.             |

***

### Example Use Case

#### Download File Content

```bash
GET /mbse/api/1.0/content?
projectId=123
&fileLocationUri=https://example.com/files/block-diagram.png
```

***

### Implementation Guidelines

* Do not transform or decode file bytes.
* Use streaming APIs where supported.
* Handle large files efficiently.
* Ensure streams are properly closed after transmission.

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.opshub.com/v7.229-1/mbse-connector-sdk-index/mbse-sdk-connector-apis/file-apis/file-get.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
