2024-10-15 10:50:56 +03:00
|
|
|
---
|
2024-10-15 10:16:04 +03:00
|
|
|
sidebar_position: 4
|
|
|
|
---
|
|
|
|
|
2024-10-15 10:50:56 +03:00
|
|
|
import Tabs from '@theme/Tabs';
|
|
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
|
2024-10-15 10:16:04 +03:00
|
|
|
# Upload file
|
|
|
|
Uploads a file to the drive
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
`Function UploadFile(Val Token, Val File, Val Description) Export`
|
|
|
|
|
|
|
|
| Parameter | CLI option | Type | 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/>
|
|
|
|
|
2024-10-15 13:51:58 +03:00
|
|
|
:::tip
|
|
|
|
Parameters with Binary data type can also accept file paths on disk and URLs
|
|
|
|
:::
|
|
|
|
<br/>
|
2024-10-15 10:16:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
```bsl title="Code example"
|
|
|
|
Token = "ya29.a0AcM612zdAe2M8Ywdxt7xmK1VAAj2m3yjTdP1Ap8cFmqbE8lVngjIAujPtjc_c94MCuKNLfn7MSssBd6NfMXDQDrHMUv7Fgjp7cjuXk68n...";
|
|
|
|
Image = "https://api.athenaeum.digital/test_data/picture.jpg";
|
|
|
|
Directory = "191iyaa6-2BCNRPOF0F8mQ0TuNWPNesdM";
|
|
|
|
|
|
|
|
Description = OPI_GoogleDrive.GetFileDescription();
|
|
|
|
Description.Insert("Parent", Directory);
|
|
|
|
|
|
|
|
Result = OPI_GoogleDrive.UploadFile(Token, Image, Description);
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```json title="Result"
|
|
|
|
{
|
|
|
|
"kind": "drive#file",
|
|
|
|
"id": "1iscrZRfSVq4khO1E3n-uSbfSFDTZfYdE",
|
|
|
|
"name": "New file.jpg",
|
|
|
|
"mimeType": "image/jpeg"
|
|
|
|
}
|
|
|
|
```
|