Google Drive avatar
Google Drive
Try for free

No credit card required

View all Actors
Google Drive

Google Drive

onidivo/google-drive
Try for free

No credit card required

Transfer files between Apify's key-value stores and Google Drive.

Google Drive Actor

Transfer files between Apify's key-value stores and Google Drive.

Input

The input is a JSON object with the following fields.

FieldTypeDescriptionDefault valuePossible valuesRequired
constantsarrayConstants to use in the operations--false
constants[*]objectConstant settings---
constants[name]stringConstant name--true
constants[value]string or ObjectConstant value--true
operationsarrayThe operations to execute--false
operations[*]ObjectOperation settings, mainly it contains the type and other specific settings---
fileUploadTimeoutSecsnumberMaximum available time (in seconds) used to upload a single file120-false
fileUploadingMaxConcurrencynumberMaximum concurrency used for uploading files in parallel--false
isSetupModebooleanWhether yes or no to activate the setup modefalse-false
googleOAuthTokensStorestringKey-value store where your Google OAuth tokens will be stored so you don't have to authorize every time again"google-oauth-tokens"-false
googleOAuthCredentialsobjectGoogle OAuth credentials--false

Constants

An array of folder info constants to use by the operations (DRY principle). Each constant is a JSON object composed of two fields: name and value.

Constant value as string

Represent the path of the folder

Example

1{
2      "name": "myFolder",
3      "value": "my-project/files"
4}

Constant value as object

Provide more folder definition, which can be useful for defining a shared folder.

Example

1{
2      "name": "myFolder",
3      "value": {
4            "parentFolderId": "GoogleDriveFolderId",
5            "path": "files"
6      }
7}

Constant usage

We use the constant inside a string with the following format "constants.[CONSTANT_NAME]".

Example

1{
2      "type": "folders-delete",
3      "folder": "constants.myFolder"
4  }

Operations

Operations are the backbone. Each operation is an object and distinguished by the type field. The field type can have one the following values: upload, and folders-delete.

For each operation type there are specific settings that accompany as explained below:

Operation "upload"

Upload files from the key-value stores to a Google Drive folder.

FieldTypeDescriptionDefault valuePossible valuesRequired
sourceobjectRepresent the file(s) to upload--true
source.idOrNamestringThe ID or name of the key-value store--true
source.forceCloudbooleanForcibly use the key-value store from the cloudfalse-false
source.filesarrayFile(s) to apply the operation on them
source.files[*]objectFile(s) settings--true
source.files[key]stringThe key of the file on the key-value store--true
source.files[name]stringThe name of upload file on Google Drive--false
source.files[mimeType]stringThe Google Drive MIME type of the file-Google Drive MIME typesfalse
destinationstring / objectInfo of the Google Drive's folder where we will upload the file(s)--true

Example

1{
2      "type": "upload",
3      "source": {
4        "idOrName": "my-store",
5        "files": [
6            {
7              "key": "my_spreadsheet",
8              "name": "My spreadsheet",
9              "mimeType": "application/vnd.google-apps.spreadsheet"
10            },
11            {
12              "key": "my_image",
13              "name": "My Image"
14            }
15        ]
16      },
17      "destination": "My actor files"
18    }

Operation "folders-delete"

Delete a folder. This operation type is useful for deleting folders before uploading files to prevent file duplication.

FieldTypeDescriptionDefault valuePossible valuesRequired
folderstring / objectInfo of the Google Drive's folder to delete--true

Example:

1{
2      "type": "folders-delete",
3      "folder": "My Folder"
4}

Is setup mode

Before you start using the actor for running operations, you will need to run it in the setup mode. To achieve that, you need to run it with the bellow input and follow the steps in the run's log ( for more info, check this article).

1{
2  "isSetupMode": true
3}

Note: If the setup mode is activated, operations will not get executed.

Google OAuth credentials

If you want to use this actor locally or with your own version, you have to provide your own credentials. To setup yours, check this guide. Required credentials data is: "client_id", "client_secret", and "redirect_uri".

Developer
Maintained by Community
Actor metrics
  • 2 monthly users
  • 99.9% runs succeeded
  • 0.0 days response time
  • Created in Apr 2020
  • Modified 12 months ago
Categories