disk.folder.uploadfile
disk.folder.uploadfile
Uploads a new file to the specified folder.
In case of a successful upload, it returns the structure similar to disk.file.get.
Parameters
Parameter | Description |
---|---|
id | Folder ID. |
fileContent | Similar to 'DETAIL_PICTURE' in the example Files Processing. |
data | An array describing the file. Mandatory field NAME is the name of a new file. |
Example
BX24.callMethod( "disk.folder.uploadfile", { id: 4, data: { NAME: "avatar.jpg" }, fileContent: document.getElementById('test_file_input') }, function (result) { if (result.error()) console.error(result.error()); else console.dir(result.data()); } );
Exampe of a direct file upload to Drive24
- First, we should call /rest/disk.folder.uploadFile and pass to the method only the ID of the folder
- As the response we receive the UploadUrl parameter and the field parameter:
- To the received UploadUrl, send POST-request to multipart/form-data, where we pass the file to the field with the name, received in the field parameter:
- As a response, we receive data about the uploaded file:
disk.folder.uploadFile?auth=n2423m863oil59f99c9g0bm4918l5erz&id=289
"result": { "field": "file", "uploadUrl": "http://b24.sigurd.bx/rest/upload.json?auth=n2423m863oil59f99c9g0bm4918l5erz&token=disk%7CaWQ9Mjg5Jl89QkYzazEzaXNnUjNHcVZQcDJZaGxGRmI4TGhXOG5EZXQ%3D%7CInVwbG9hZHxkaXNrfGFXUTlNamc1Smw4OVFrWXphekV6YVhOblVqTkhjV lpRY0RKWmFHeEdSbUk0VEdoWE9HNUVaWFE9fG4yNDIzbTg2M29pbDU5Zjk5YzlnMGJtNDkxOGw1ZXJ6Ig%3D%3D.Aga709nyY0%2BrFiv3laHjfg6XuOO5JT6ttjU%2F53ifphM%3D" }
http --form POST "http://b24.sigurd.bx/rest/upload.json?auth=n2423m863oil59f99c9g0bm4918l5erz&token=disk%7CaWQ9Mjg5Jl89QkYzazEzaXNnUjNHcVZQcDJZaGxGRmI4TGhXOG5EZXQ%3D%7CInVwbG9hZHxkaXNrfGFXUTlNamc1Smw4OVFrWXp hekV6YVhOblVqTkhjVlpRY0RKWmFHeEdSbUk0VEdoWE9HNUVaWFE9fG4yNDIzbTg2M29pbDU5Zjk5YzlnMGJtNDkxOGw1ZXJ6Ig%3D%3D.Aga709nyY0%2BrFiv3laHjfg6XuOO5JT6ttjU%2F53ifphM%3D" file@~/somelongfile.log
"result": { "CODE": null, "CREATED_BY": "1", "CREATE_TIME": "2016-03-30T14:30:41+02:00", "DELETED_BY": null, "DELETED_TYPE": 0, "DELETE_TIME": null, "DETAIL_URL": "http://b24.sigurd.bx/company/personal/user/1/disk/file/Тестируем REST/somelongfile.log", "DOWNLOAD_URL": "http://b24.sigurd.bx/rest/download.json?auth=n2423m863oil59f99c9g0bm4918l5erz&token=disk%7CaWQ9MjkwJl89ZTI4MG9TcDZCQno2MDAwVmV3cnRkbWxLM2hLN0JweEs%3D%7CImRvd25sb2FkfGRpc2t8YVdROU1qa3dKbDg5WlRJNE1HOVRjRFpD UW5vMk1EQXdWbVYzY25Sa2JXeExNMmhMTjBKd2VFcz18bjI0MjNtODYzb2lsNTlmOTljOWcwYm00OTE4bDVlcnoi.QlpUpx4mG9sxeyMyholPfdgkoXgc9kK9gtbOagqSo7s%3D", "FILE_ID": 209, "GLOBAL_CONTENT_VERSION": 1, "ID": 290, "NAME": "somelongfile.log", "PARENT_ID": "289", "SIZE": "496136787", "STORAGE_ID": "1", "TYPE": "file", "UPDATED_BY": "1", "UPDATE_TIME": "2016-03-30T14:30:43+02:00" }
© «Bitrix Inc.»,
2001-2021,
«Bitrix Inc.», 2021
User Comments
User comments are not part of official documentation. Use information provided by other users in the comments at your own risk.The User Comments section is not to be used as a feature discussion board. Only registered users can post comments. Your comment will be visible once it has been approved by the moderator.