# File Node

### **File Node Overview**

The File node is a PIN path specifically designed for storing files. Through the File node, users can securely store files on the blockchain in the form of PINs, achieving decentralized file storage and management.

### **Data Format**

The PIN content for storing files follows this format:

```go
OP_FALSE
OP_IF
	metaid            
	create             
	/file/file-name-1.jpg     
	0                  
	OP_0               
	image/jpg;binary   
	<file data>        // Payload - Binary content of the file
OP_ENDIF
```

Here, **`<file data>`** contains the binary content of the file, and **`content-type`** specifies the file's data type (for example, image/jpg;binary indicates a JPEG image file).

### **File Node Path**

The path for the File node uses **`/file`** as the base path and can further distinguish different files through file names or sub-paths. Through the File node path, users can easily locate and retrieve specific file PINs in the MetaID tree structure, thereby achieving effective organization and management of files.

### **File Referencing**

In MetaID, file referencing is a fundamental business operation with critical importance. This feature allows users to reference existing on-chain **`file`** data in application protocols, enhancing data connectivity and user experience. To achieve this, we define a special file referencing rule.

#### **File Referencing Format**

When referencing a **`file`** in a sub-protocol, such as in the **`payload`**, we use the following format:

```arduino
metafile://{pinid}
```

Here, `PINID` is the unique identifier of the file to be referenced. This format allows us to establish a reference link from the current protocol to a specific **`file`**.

<figure><img src="/files/2zHnkap0lxEPcBRnq5tE" alt=""><figcaption></figcaption></figure>

#### Example

For example, posting with an attached file:

```json
//Payload
{
	"content":"Hello bitcoin world!",
	"contentType":"text/plain",
	"createTime":1710741614716,
	"quoteTx":"",
	"attachment":[
		"metafile://{pinId}"
	]
}
```

The final on-chain content will be:

```json
OP_FALSE
OP_IF
	metaid                           // Protocol identifier
	create                          // Operation type
	/protocols/simplebuzz         // Path
	0                                // Encryption type (0 means no encryption)
	0                                // Version
	application/json;utf-8              // Content-type
	{"content":"Hello bitcoin world!","contentType":"text/plain","createTime":1710741614716,"quoteTx":"","attachment":["metafile://{pinId}"]}       // Payload
OP_ENDIF
```

<br>


---

# Agent Instructions: 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:

```
GET https://docs.metaid.io/metaid-specification/metaid-tree/file-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
