Skip to main content

Upload file

Uploads a file to the drive

Function UploadFile(Val Token, Val File, Val Description) Export

ParameterCLI optionTypeRequiredDescription
Token--tokenStringToken
File--fileBinaryData, StringFile to be uploaded
Description--propsMap Of KeyAndValueSee GetFileDescription
Returns

Map Of KeyAndValue - serialized JSON response from Google

tip

Parameters with Binary data type can also accept file paths on disk and URLs


1C:Enterprise/OneScript code example
Token = "ya29.a0ATi6K2sWW_31WLH0d9aK0qk0HJ-UfyvZDcLeBbF5bLU7QH09Bx2pXAupIw40USQVaxXqsovItVSt9swWuPdBDSA0eFaVPE0CbaU2OLQlyrnITI1VVXgZ_Gx2R...";
Directory = "1RA5EV-HEr2SDzooZLmZ2h6HnnmZ0EHzP";
Image = "https://hut.openintegrations.dev/test_data/picture.jpg"; // URL, Binary data or File path

Clear = False;
Description = OPI_GoogleDrive.GetFileDescription(Clear);

Description.Insert("Parent", Directory);

Result = OPI_GoogleDrive.UploadFile(Token, Image, Description);
# 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':'1T61ve0vc7hRiV8RYiMcBqR0GH3umkYDN'}"
Result
{
"kind": "drive#file",
"id": "1GqDkU__lzFdSj2KRtdxeUTO0xgN_cThi",
"name": "New file.jpg",
"mimeType": "image/jpeg"
}