在PhpStorm中,有一种方法可以配置多个SFTP终端并选择要上传到哪个服务器。我正在寻找Visual Studio Code中的此功能。我已安装SFTP VS Code扩展程序,并且能够为一个终端进行配置。如果我想将文件上传到多个服务器怎么办?我该如何配置?或者是否有另一个扩展程序可以实现这一点?
你可以在配置中添加多个FTP服务器。只需确保context不同即可。
[
{
"name": "server1",
"context": "/project/build",
"host": "host",
"username": "username",
"password": "password",
"remotePath": "/remote/project/build"
},
{
"name": "server2",
"context": "/project/src",
"host": "host",
"username": "username",
"password": "password",
"remotePath": "/remote/project/src"
}
]
/
开始。我建议将它们设置为相对于您的默认SFTP文件夹,例如./path/to/server1files
。 - DiegoDD现在您可以使用SFTP扩展中的“配置文件”。https://github.com/liximomo/vscode-sftp#profiles
{
"name": "My Project",
"protocol": "sftp",
"remotePath": "/",
"port": 22,
"profiles": {
"dev": {
"host": "server1.example.com",
"username": "username",
"password": "password"
},
"prod": {
"host": "server2.example.com",
"username": "other-username",
"password": "other-password"
}
},
"defaultProfile": "dev"
}
{
"name": "ExampleName",
"protocol": "sftp",
"port": 22,
"profiles": {
"profile1": {
"host": "connection1",
"username": "user1",
"remotePath":"/path1"
},
"profile2": {
"host": "connection2",
"username": "user2",
"remotePath":"/path2"
},
"profile3": {
"host": "connection3",
"username": "user3",
"remotePath":"/path3"
},
}
}
通过按下 Ctrl+Shift+P > Set Profile,您可以更改您的个人资料。
试试这个:
[
{
"name": "project 1",
"context": "/project/project1",
"host": "",
"username": "",
"password": "",
"protocol": "ftp",
"post": 21,
"remotePath": "/",
"uploadOnSave": true
},
{
"name": "project 2",
"context": "/project/project2",
"host": "",
"username": "",
"password": "",
"protocol": "ftp",
"post": 21,
"remotePath": "/",
"uploadOnSave": true
}
]
[
{
"name": "server1",
"context": "/project/build",
"host": "host",
"username": "username",
"password": "password",
"remotePath": "/remote/project/build"
},
{
"name": "server2",
"context": "/project/src",
"host": "host",
"username": "username",
"password": "password",
"remotePath": "/remote/project/src"
}
]