> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 执行蓝牙 FTP 客户端功能

> 您可以使用 ``obexctl`` 主菜单中提供的命令验证蓝牙 FTP 客户端功能。蓝牙 FTP 客户端功能包括创建新文件夹和更改当前文件夹以浏览文件系统。使用 FTP 客户端功能，您可以检索当前文件夹的信息、将文件复制到远程设备、从远程设备复制文件、在远程设备内复制文件、在不同位置之间移动文件，以及在不再需要时删除文件。

<a id="bluez-perform-bluetooth-ftp-server-and-client-functions" />

<Note>
  测试或验证 FTP 服务器功能不需要测试应用程序。请通过客户端连接执行 FTP 功能。
</Note>

## 前提条件

开始之前，请按照 <a href="verify-ftp-functions#set-up-the-device-for-bluetooth-ftp-functions" target="_self">为蓝牙 FTP 功能设置设备</a> 中的说明设置设备。

## 创建文件夹

要在远程设备上创建文件夹，请在 `obexctl` 菜单中运行以下命令：

```text theme={null}
mkdir <folder_name>
```

您可以在服务器的 `/var/bluetooth` 目录验证文件夹是否创建成功。

**参数**

`<folder_name>` 是新文件夹的名称。

**示例**

要创建名为 `new_dir` 的文件夹，请运行以下命令：

```text theme={null}
mkdir new_dir
```

**示例输出**

```text theme={null}
#mkdir new_dir
Attempting to CreateFolder
CreateFolder successful
```

## 更改当前文件夹

要更改远程设备的当前文件夹，请在 `obexctl` 菜单中运行以下命令：

```text theme={null}
cd <folder_path>
```

**参数**

`<folder_path>` 是您要切换到的文件夹。

**示例**

要将当前文件夹更改为 `new_dir`，请运行以下命令：

```text theme={null}
cd new_dir
```

**示例输出**

```text theme={null}
#cd new_dir
Attempting to ChangeFolder to new_dir
ChangeFolder successful
```

## 获取当前文件夹信息

要获取当前文件夹的信息，请在 `obexctl` 菜单中运行以下命令：

```text theme={null}
ls .
```

**示例输出**

```text theme={null}
# ls .
Attempting to ListFolder
[NEW] Transfer /org/bluez/obex/client/session7/transfer4
[CHG] Transfer /org/bluez/obex/client/session7/transfer4 Size: 611
[CHG] Transfer /org/bluez/obex/client/session7/transfer4 Status: complete
      Type: folder
      Name: My_folder
      User-perm: RWD
      Group-perm: R
      Other-perm:
      Accessed: 20231214T123503Z
      Modified: 20231214T123502Z
      Created: 20231214T123502Z
      Type: folder
      Name: new_dir
      User-perm: RWD
      Group-perm: R
      Other-perm:
      Accessed: 20231215T093311Z
      Modified: 20231215T093245Z
      Created: 20231215T093245Z
```

## 将文件复制到远程设备

要将本地文件复制到远程设备，请在 `obexctl` 菜单中运行以下命令：

```text theme={null}
cp :<source_file> <destination_file>
```

**参数**

* `<source_file>` 是本地文件。

* `<destination_file>` 是远程设备上的目标文件。

**示例**

要将位于 `Documents/ftp_client.txt` 的本地文件复制到远程设备上的 `ftp_client.txt`，请运行以下命令：

```text theme={null}
cp :Documents/ftp_client.txt ftp_client.txt
```

**示例输出**

```text theme={null}
# cp :Documents/ftp_client.txt ftp_client.txt
Attempting to PutFile
[NEW] Transfer /org/bluez/obex/client/session7/transfer5
Transfer /org/bluez/obex/client/session7/transfer5
      Status: queued
      Name: ftp_client.txt
      Size: 10
      Filename: Documents/ftp_client.txt
      Session: /org/bluez/obex/client/session7
[CHG] Transfer /org/bluez/obex/client/session7/transfer5 Status: complete
[DEL] Transfer /org/bluez/obex/client/session7/transfer5
```

## 从远程设备复制文件

开始之前，请<a href="#change-the-current-folder" target="_self">更改当前文件夹</a>到目标文件所在的文件夹。

要将文件从远程设备复制到本地目录，请在 `obexctl` 菜单中运行以下命令：

```text theme={null}
cp <destination_file> :<source_file>
```

**参数**

* `<source_file>` 是远程设备上的文件。

* `<destination_file>` 是本地设备上的目标文件。

**示例**

要将 `ftp_client_2.txt` 文件从远程设备复制到本地设备，请运行以下命令：

```text theme={null}
cp ftp_client_2.txt :ftp_client_2.txt
```

**示例输出**

```text theme={null}
# cp ftp_client_2.txt :ftp_client_2.txt
Attempting to GetFile
[NEW] Transfer /org/bluez/obex/client/session7/transfer21
Transfer /org/bluez/obex/client/session7/transfer21
      Status: queued
      Name: ftp_client_2.txt
      Size: 0
      Filename: ftp_client_2.txt
      Session: /org/bluez/obex/client/session7
[CHG] Transfer /org/bluez/obex/client/session7/transfer21 Size: 13
[CHG] Transfer /org/bluez/obex/client/session7/transfer21 Status: complete
[DEL] Transfer /org/bluez/obex/client/session7/transfer21
```

## 在远程设备内复制文件

要在远程设备上将文件从一个目录复制到另一个目录，请在 `obexctl` 菜单中运行以下命令：

```text theme={null}
cp <source_file> <destination_file>
```

**参数**

* `<source_file>` 是您要复制的文件。

* `<destination_file>` 是目标位置。

**示例**

要将 `ftp_client.txt` 复制到 `/new_dir_2/`，请运行以下命令：

```text theme={null}
cp ftp_client.txt ../new_dir_2/ftp_client.txt
```

**示例输出**

```text theme={null}
# cp ftp_client.txt ../new_dir_2/ftp_client.txt
Attempting to CopyFile
CopyFile successful
```

## 移动文件

要在远程设备上将文件从一个文件夹移动到另一个文件夹，请在 `obexctl` 菜单中运行以下命令：

```text theme={null}
mv <source_file> <destination_file>
```

**参数**

* `<source_file>` 是您要移动的文件。

* `<destination_file>` 是目标位置。

**示例**

要将 `ftp_client_2.txt` 文件移动到 `/new_dir_2/`，请运行以下命令：

```text theme={null}
mv ftp_client_2.txt ../new_dir_2/ftp_client_2.txt
```

**示例输出**

```text theme={null}
#mv ftp_client_2.txt ../new_dir_2/ftp_client_2.txt
Attempting to MoveFile
MoveFile successful
```

## 删除文件

要删除文件，请在 `obexctl` 菜单中运行以下命令：

```text theme={null}
rm <filename>
```

**参数**

`<filename>` 是您要删除的文件。

**示例**

要删除 `ftp_client.txt` 文件，请运行以下命令：

```text theme={null}
rm ftp_client.txt
```

**示例输出**

```text theme={null}
# rm ftp_client.txt
Attempting to Delete
Delete successful
```
