Search

Upload File

Last Updated: Mar 15, 2021

Articles

Use this function to upload the specified file in a selected folder to the Google Drive instance.

Syntax

Upload File (upload_file_path, upload_file_name, parent_folder_id, attachment_type, private_key, client_email)

Parameters

Input Parameter Name Description
upload_file_path Path of the file to be uploaded
upload_file_name Name of the file to be uploaded
parent_folder_id ID of the folder where the file has to be uploaded
attachment_type MIME type of the type of file to be uploaded
For more information, refer to the below table Attachment Types
private_key Private key of the service account
client_email Email ID of the service account

Returns

Return Value Description
Output
  • On Success returns 1, ID of the uploaded file
  • On Failure returns 0, Error Message

Sample

Upload File (C:\Downloads, Invoice.pdf, ABC123, application/pdf, —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—–, name@project-id.iam.gserviceaccount.com)

  • Uses the private key —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—– to connect to the Email ID name@project-id.iam.gserviceaccount.com, uploads the file *Invoice.pdf*of type application/pdf from the path C:\Downloads to the destination folder with ID ABC123.
    Returns the ID of the uploaded file on uploading the file.

Attachment Types

MIME Type Attachment Type
application/msword .doc
application/vnd.openxmlformats-officedocument.wordprocessingml.document .docx
application/vnd.ms-excel .xls
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .xlsx
application/vnd.ms-powerpoint .ppt
application/vnd.openxmlformats-officedocument.presentationml.presentation .pptx
application/pdf .pdf
image/jpeg .jpeg
image/png .png
text/css .css
text/csv .csv
text/html .html

This list is not exhaustive.

To view all the Google Drive functions, click here.

Did you find what you were looking for?