common.md 1.24 KB
Newer Older
Wei Shoulin's avatar
docs  
Wei Shoulin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 通用接口使用说明

## 概述

该模块包含了从指定路径下载文件、读取文件、获取文件头信息的函数。

## 函数列表

1. **download_file**
   - 功能: 从指定路径下载文件。
   - 参数: 文件相对路径。
   - 返回值:字节。

2. **read_file**
   - 功能: 读取指定路径的文件。
   - 参数: 文件相对路径。
   - 返回值:io.BytesIO。

3. **get_free_header**
   - 功能: 获取指定文件路径的文件头信息。
   - 参数: 文件相对路径。
   - 返回值:dict。

## 示例

### 1. `download_file` 函数

```python
from csst_dfs_client import download_file

try:
    file_content = download_file("path/to/your/file")
    print(type(file_content))
except AppError as e:
    print(f"Error: {e}")
```

### 2. `read_file` 函数

```python
from csst_dfs_client import read_file

try:
    file_io = read_file("path/to/your/file.txt")
    print(file_io.getvalue())
except AppError as e:
    print(f"Error: {e}")
```

### 3. `get_free_header` 函数

```python
from csst_dfs_client import get_free_header

try:
    header_info = get_free_header("path/to/your/file.txt")
    print(header_info)
except AppError as e:
    print(f"Error: {e}")
```

- [其他接口](./usage.md)