disk.file.copyTo
Копировать файл в указанную папку
Описание
Метод disk.file.copyTo копирует файл в указанную папку.
Параметры
id
integer
обязательный
Идентификатор файла
targetFolderId
integer
обязательный
Идентификатор папки, в которую копируется файл
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"id":9035,"targetFolderId":8930}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/disk.file.copyTo
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"id":9035,"targetFolderId":8930,"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/disk.file.copyTo
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame, ISODate } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
// Shape of the payload returned in result (match the "response handling" section of the page)
type DiskFileCopyToResult = {
ID: number
NAME: string
CODE: string | null
STORAGE_ID: string
TYPE: string
PARENT_ID: string
DELETED_TYPE: number
GLOBAL_CONTENT_VERSION: number
FILE_ID: number
SIZE: string
CREATE_TIME: ISODate | null
UPDATE_TIME: ISODate | null
DELETE_TIME: ISODate | null
CREATED_BY: string
UPDATED_BY: string
DELETED_BY: string | null
DOWNLOAD_URL: string
DETAIL_URL: string
}
try {
const response = await $b24.actions.v2.call.make<DiskFileCopyToResult>({
method: 'disk.file.copyTo',
params: {
id: 9035,
targetFolderId: 8930,
},
requestId: Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
const result = response.getData()!.result
console.info('Copied file:', result.ID, result.NAME, result.DOWNLOAD_URL)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function copyFileTo() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'disk.file.copyTo',
params: {
id: 9035,
targetFolderId: 8930,
},
requestId: B24Js.Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
const result = response.getData().result
console.info('Copied file:', result.ID, result.NAME, result.DOWNLOAD_URL)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', copyFileTo)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
try:
bitrix_response = client.disk.file.copyto(
bitrix_id=9035,
target_folder_id=8930,
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Ошибка Bitrix API",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
print(f"Непредвиденная ошибка: {error}")
try {
$response = $b24Service
->core
->call(
'disk.file.copyTo',
[
'id' => 9035,
'targetFolderId' => 8930
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
processData($result);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error copying file: ' . $e->getMessage();
}
BX24.callMethod(
"disk.file.copyTo",
{
id: 9035,
targetFolderId: 8930
},
function (result)
{
if (result.error())
console.error(result.error());
else
console.dir(result.data());
}
);
require_once('crest.php');
$result = CRest::call(
'disk.file.copyTo',
[
'id' => 9035,
'targetFolderId' => 8930
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "disk.file.copyTo", b24.Params{
"id": 9035,
"targetFolderId": 8930,
})
if err != nil {
return fmt.Errorf("disk.file.copyTo: %w", err)
}
var item struct {
ID b24.ID `json:"ID"`
Name string `json:"NAME"`
StorageID b24.ID `json:"STORAGE_ID"`
Type string `json:"TYPE"`
ParentID b24.ID `json:"PARENT_ID"`
DeletedType int `json:"DELETED_TYPE"`
}
if err := json.Unmarshal(res.Result, &item); err != nil {
return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println(item.ID, item.Name)
Ответ
HTTP-статус: 200
{
"result": {
"ID": 9037,
"NAME": "picture.png",
"CODE": null,
"STORAGE_ID": "1357",
"TYPE": "file",
"PARENT_ID": "8930",
"DELETED_TYPE": 0,
"GLOBAL_CONTENT_VERSION": 1,
"FILE_ID": 32933,
"SIZE": "1679",
"CREATE_TIME": "2026-02-09T11:35:49+03:00",
"UPDATE_TIME": "2026-02-09T11:35:49+03:00",
"DELETE_TIME": null,
"CREATED_BY": "1269",
"UPDATED_BY": "1269",
"DELETED_BY": null,
"DOWNLOAD_URL": "https://test.bitrix24.ru/rest/download.json?auth=effc89690000071b006e2cf2000004f50000077d3d5d904ee6ccfc65bf287ca71f1fd6&token=disk%7CaWQ9OTAzNyZfPVhsRFgwaWJ2RTdLMXJlV1dhaEFPMEtoTjhVQ0s0MWNx%7CImRvd25sb2FkfGRpc2t8YVdROU9UQXpOeVpmUFZoc1JGZ3dhV0oyUlRkTE1YSmxWMWRoYUVGUE1FdG9UamhWUTBzME1XTnh8ZWZmYzg5NjkwMDAwMDcxYjAwNmUyY2YyMDAwMDA0ZjUwMDAwMDc3ZDNkNWQ5MDRlZTZjY2ZjNjViZjI4N2NhNzFmMWZkNiI%3D.fY5cpLbXwIiIO8X3NoiCzsMVAl2i6zegF4%2Bn86l0khg%3D",
"DETAIL_URL": "https://test.bitrix24.ru/company/personal/user/1269/disk/file/Папка/Папка в папке/picture.png"
},
"time": {
"start": 1770647749,
"finish": 1770647749.342314,
"duration": 0.3423140048980713,
"processing": 0,
"date_start": "2026-02-09T11:35:49+03:00",
"date_finish": "2026-02-09T11:35:49+03:00",
"operating_reset_at": 1770648349,
"operating": 0.1015939712524414
}
}
Возвращаемые данные
result
array
Массив с полями файла
ID
integer
Идентификатор файла
NAME
string
Имя файла
CODE
string
Символьный код файла
STORAGE_ID
integer
Идентификатор хранилища, в котором находится файл
TYPE
enum
Тип объекта
PARENT_ID
integer
Идентификатор родительской папки
DELETED_TYPE
enum
Статус удаления объекта. Возможные значения:
- 0 — не удален
- 3 — в корзине
- 4 — удален вместе с родительской папкой
GLOBAL_CONTENT_VERSION
integer
Инкрементальный счетчик версии файла
FILE_ID
integer
Внутреннее значение идентификатора файла
SIZE
integer
Размер файла в байтах
CREATE_TIME
datetime
Дата и время создания файла
UPDATE_TIME
datetime
Дата и время последнего обновления файла
DELETE_TIME
datetime
Дата и время переноса файла в корзину
CREATED_BY
integer
Идентификатор пользователя, создавшего файл
UPDATED_BY
integer
Идентификатор пользователя, внесшего последнее изменение
DELETED_BY
integer
Идентификатор пользователя, удалившего файл
DOWNLOAD_URL
string
Ссылка для скачивания файла
DETAIL_URL
string
Ссылка для открытия файла в интерфейсе
time
time
Информация о времени выполнения запроса
Обработка ошибок
HTTP-статус: 400
{
"error":"ERROR_ARGUMENT",
"error_description":"Invalid value of parameter {Parameter #0}"
}
| Код | Описание | Значение |
|---|---|---|
ERROR_ARGUMENT |
Invalid value of parameter {Parameter #0} | Не указан обязательный параметр id или targetFolderId |
DISK_OBJ_22000 |
Файл с таким именем уже есть | Файл с таким именем уже есть |
DISK_FILE_22003 |
Could not copy file | Ошибка при создании копии файла в базе данных |
ERROR_NOT_FOUND |
Could not find entity with id X |
Файл с указанным id или папка с указанным targetFolderId не найдены |
ACCESS_DENIED |
Access denied | Недостаточно прав для копирования файла |

