Skip to main content

Upload file

Uploads a file to disk at the specified path

Function UploadFile(Val Token, Val Path, Val File, Val Overwrite = False) Export

ParameterCLI optionTypeRequiredDescription
Token--tokenStringToken
Path--pathStringPath for saving the file to disk
File--fileString, BinaryDataFile for upload
Overwrite--rewriteBooleanOverwrite if a file with the same name already exists

Returns: Map Of KeyAndValue - serialized JSON response from Yandex


tip

Parameters with Binary data type can also accept file paths on disk and URLs


1C:Enterprise/OneScript code example
    Path1 = "/" + String(New UUID) + ".png";
Path2 = "/" + String(New UUID) + ".png";

Token = "y0_AgAAAABdylaOAAs0QgAAAAD5i-a...";
Image = "https://api.athenaeum.digital/test_data/picture.jpg"; // URL

TFN = GetTempFileName("png"); // Path
CopyFile(Image, TFN);

Result = OPI_YandexDisk.UploadFile(Token, Path1, Image, True);

Result = OPI_YandexDisk.UploadFile(Token, Path2, TFN, True);
    oint yadisk UploadFile \
--token "***" \
--path "/8ed47363-93c2-4a70-8bfe-45976d3391c5.png" \
--file "C:\Users\Administrator\AppData\Local\Temp\nihbtitcw1k.png" \
--rewrite true
Result
{}