1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-29 22:27:42 +02:00
Files
OpenIntegrations/docs/en/md/SFTP/Common-methods/Update-path.mdx
Vitaly the Alpaca (bot) 9be4b23629 Main build (Jenkins)
2025-10-31 15:42:42 +03:00

115 lines
3.8 KiB
Plaintext
Vendored

---
sidebar_position: 4
description: Update path and other functions to work with SFTP in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, SFTP]
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Update path
Changes the object's path to the specified one
`Function UpdatePath(Val Connection, Val Path, Val NewPath, Val Overwrite = False) Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Connection | --conn | Arbitrary | ✔ | Existing connection or connection configuration |
| Path | --old | String | ✔ | Current path to object |
| NewPath | --new | String | ✔ | New path to object |
| Overwrite | --rw | Boolean | ✖ | Overwrite if an object already exists at the target path |
Returns: Map Of KeyAndValue - Processing result
<br/>
```bsl title="1C:Enterprise/OneScript code example"
Host = "172.33.0.13";
Port = "2222";
UseProxy = True;
ProxySettings = Undefined;
AuthorizationType = "By login and password";
If AuthorizationType = "By login and password" Then
Login = "bayselonarrend";
Password = "12we...";
SFTPSettings = OPI_SFTP.GetSettingsLoginPassword(Host, Port, Login, Password);
ElsIf AuthorizationType = "By key" Then
Login = "bayselonarrend";
PrivateKey = "./ssh_key";
PublicKey = "./ssh_key.pub";
SFTPSettings = OPI_SFTP.GetSettingsPrivateKey(Host, Port, Login, PrivateKey, PublicKey);
Else
Login = "bayselonarrend";
SFTPSettings = OPI_SFTP.GetSettingsViaAgent(Host, Port, Login);
EndIf;
If UseProxy Then
ProxyType = "http"; // http, socks5, socks4
ProxyAddress = "127.0.0.1";
ProxyPort = "8071";
ProxyLogin = "proxyuser";
ProxyPassword = "12we...";
ProxySettings = OPI_SFTP.GetProxySettings(ProxyAddress, ProxyPort, ProxyType, ProxyLogin, ProxyPassword);
EndIf;
Connection = OPI_SFTP.CreateConnection(SFTPSettings, ProxySettings);
If OPI_SFTP.IsConnector(Connection) Then
Result = OPI_SFTP.UpdatePath(Connection, "pic_from_disk.png", "files_folder/pic_from_disk.png");
Else
Result = Connection; // Error of connection
EndIf;
```
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
# JSON data can also be passed as a path to a .json file
oint sftp UpdatePath \
--conn "{'proxy':{'login':'proxyuser','password':'***','port':'8071','proxy_type':'http','server':'127.0.0.1'},'set':{'auth_type':'private_key','host':'172.33.0.13','key_path':'***','passphrase':null,'password':null,'port':'2222','pub_path':'C:\\Users\\bayse\\AppData\\Local\\Temp\\thelujl0.a11.tmp','username':'bayselonarrend'}}" \
--old "files_folder/pic_from_disk.png" \
--new "pic_from_disk.png"
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
:: JSON data can also be passed as a path to a .json file
oint sftp UpdatePath ^
--conn "{'proxy':{'login':'proxyuser','password':'***','port':'8071','proxy_type':'http','server':'127.0.0.1'},'set':{'auth_type':'private_key','host':'172.33.0.13','key_path':'***','passphrase':null,'password':null,'port':'2222','pub_path':'C:\\Users\\bayse\\AppData\\Local\\Temp\\thelujl0.a11.tmp','username':'bayselonarrend'}}" ^
--old "files_folder/pic_from_disk.png" ^
--new "pic_from_disk.png"
```
</TabItem>
</Tabs>
```json title="Result"
{
"result": true
}
```