1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-27 22:18:36 +02:00
Files
OpenIntegrations/docs/en/md/GoogleDrive/File-and-directory-management/Upload-file.mdx
Vitaly the Alpaca (bot) cdef2d02ab Main build (Jenkins)
2025-10-21 21:43:05 +03:00

82 lines
2.6 KiB
Plaintext
Vendored

---
sidebar_position: 4
description: Upload file and other functions to work with Google Drive 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, Google Drive]
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Upload file
Uploads a file to the drive
`Function UploadFile(Val Token, Val File, Val Description) Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Token | --token | String | ✔ | Token |
| File | --file | BinaryData,String | ✔ | File to be uploaded |
| Description | --props | Map Of KeyAndValue | ✔ | See GetFileDescription |
Returns: Map Of KeyAndValue - serialized JSON response from Google
<br/>
:::tip
Parameters with Binary data type can also accept file paths on disk and URLs
:::
<br/>
```bsl title="1C:Enterprise/OneScript code example"
Token = "ya29.a0AQQ_BDTEToh-GItDaON1RKItxn8oyyucs96C7wzRz-nN6Qcr3d7C5ogtN18HBpUDAewZxDbcc3jAtrj2aIO0zuU4KLYSMRkyFoLt8ZuczyuBGNtxdl-3opaY1...";
Image = "https://hut.openintegrations.dev/test_data/picture.jpg";
Directory = "191iyaa6-2BCNRPOF0F8mQ0TuNWPNesdM";
Clear = False;
Description = OPI_GoogleDrive.GetFileDescription(Clear);
Description.Insert("Parent", Directory);
Result = OPI_GoogleDrive.UploadFile(Token, Image, Description);
```
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
# JSON data can also be passed as a path to a .json file
oint gdrive UploadFile \
--token "***" \
--file "https://hut.openintegrations.dev/test_data/picture.jpg" \
--props "{'MIME':'image/jpeg','Name':'New file.jpg','Description':'This is a new file','Parent':'11Mo30odYPEtBBU_0OndFx5dz1kP7tu-Y'}"
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
:: JSON data can also be passed as a path to a .json file
oint gdrive UploadFile ^
--token "***" ^
--file "https://hut.openintegrations.dev/test_data/picture.jpg" ^
--props "{'MIME':'image/jpeg','Name':'New file.jpg','Description':'This is a new file','Parent':'11Mo30odYPEtBBU_0OndFx5dz1kP7tu-Y'}"
```
</TabItem>
</Tabs>
```json title="Result"
{
"kind": "drive#file",
"id": "1Ddwg-hig7v56qRJTDAOO2uTdnDkL4yAB",
"name": "New file.jpg",
"mimeType": "image/jpeg"
}
```