1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-04-07 07:10:01 +02:00
Vitaly the Alpaca (bot) 1cc91447b0 Main build (Jenkins)
2025-01-12 13:07:21 +03:00

79 lines
2.3 KiB
Plaintext
Vendored

---
sidebar_position: 4
---
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 | ✔ | JSON description or path to .json |
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.a0ARW5m7702-Ib_bOq69krqD5iUx89SC2lxGPxRJoBjqvSBqE7uKghOyAjwrL7ebNf6xqPzwD4wQfZlFvBrb7QsWlw5PGW_SvkFr57Y8Js...";
Image = "https://api.athenaeum.digital/test_data/picture.jpg";
Directory = "11Mo30odYPEtBBU_0OndFx5dz1kP7tu-Y";
Description = OPI_GoogleDrive.GetFileDescription();
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://github.com/Bayselonarrend/OpenIntegrations/raw/main/service/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://github.com/Bayselonarrend/OpenIntegrations/raw/main/service/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": "1iscrZRfSVq4khO1E3n-uSbfSFDTZfYdE",
"name": "New file.jpg",
"mimeType": "image/jpeg"
}
```