← Google Drive

Create Folder with Google Drive API

Pipedream makes it easy to connect APIs for Google Drive and 900+ other apps remarkably fast.

Trigger workflow on
HTTP requests, schedules and app events
Next, do this
Create Folder with the Google Drive API
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜
Trusted by 250,000+ developers from startups to Fortune 500 companies:
Trusted by 250,000+ developers from startups to Fortune 500 companies

Developers Pipedream

Getting Started

Create a workflow to Create Folder with the Google Drive API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the Create Folder action
    1. Connect your Google Drive account
    2. Optional- Select a Drive
    3. Optional- Select a Folder
    4. Optional- Configure Name
    5. Optional- Configure Create If Exists?
  2. Select a trigger to run your workflow on HTTP requests, schedules or app events
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger

Integrations

Create Folder with Google Drive API on New Requests (Payload Only) from HTTP / Webhook API
HTTP / Webhook + Google Drive
 
Try it
Create Folder with Google Drive API on New Item in Feed from RSS API
RSS + Google Drive
 
Try it
Create Folder with Google Drive API on New Message from Discord API
Discord + Google Drive
 
Try it
Create Folder with Google Drive API on New Message In Channels from Slack API
Slack + Google Drive
 
Try it
Create Folder with Google Drive API on New Message in Channel from Discord Bot API
Discord Bot + Google Drive
 
Try it

Details

This is a pre-built, open source component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Create Folder on Google Drive
Description:Create a new empty folder. [See the docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information
Version:0.0.6
Key:google_drive-create-folder

Code

import googleDrive from "../../google_drive.app.mjs";
import {
  getListFilesOpts,
  toSingleLineString,
} from "../../utils.mjs";

import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../constants.mjs";

export default {
  key: "google_drive-create-folder",
  name: "Create Folder",
  description: "Create a new empty folder. [See the docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
  version: "0.0.6",
  type: "action",
  props: {
    googleDrive,
    drive: {
      propDefinition: [
        googleDrive,
        "watchedDrive",
      ],
      optional: true,
    },
    parentId: {
      propDefinition: [
        googleDrive,
        "folderId",
        (c) => ({
          drive: c.drive,
        }),
      ],
      description:
        "Select a folder in which to place the new folder. If not specified, the folder will be placed directly in the drive's top-level folder.",
      optional: true,
    },
    name: {
      propDefinition: [
        googleDrive,
        "fileName",
      ],
      label: "Name",
      description: "The name of the new folder",
      optional: true,
    },
    createIfExists: {
      type: "boolean",
      label: "Create If Exists?",
      description: toSingleLineString(`
        If the folder already exists and is not in the trash, should we create it? This option defaults to 'true' for
        backwards compatibility and to be consistent with default Google Drive behavior. 
      `),
      optional: true,
      default: true,
    },
  },
  async run({ $ }) {
    const {
      parentId,
      name,
      createIfExists,
    } = this;
    let folder;
    if (createIfExists == false) {//checking "false" because if this optional prop may not be given
      const folders = (await this.googleDrive.listFilesInPage(null, getListFilesOpts(this.drive, {
        q: `mimeType = '${GOOGLE_DRIVE_FOLDER_MIME_TYPE}' and name contains '${name}' and trashed=false`.trim(),
      }))).files;
      for (let f of folders) {
        if (f.name == name) {
          folder = f;
          break;
        }
      }
      if (folder) {
        $.export("$summary", "Found existing folder, therefore not creating folder. Returning found folder.");
        const folderDetails = await this.googleDrive.getFile(folder.id);

        return folderDetails;
      }
    }
    const driveId = this.googleDrive.getDriveId(this.drive);
    const resp = await this.googleDrive.createFolder({
      name,
      parentId,
      driveId,
    });
    $.export("$summary", `Successfully created a new folder, "${resp.name}"`);
    return resp;
  },
};

Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
Google DrivegoogleDriveappThis component uses the Google Drive app.
DrivedrivestringSelect a value from the drop down menu.
FolderparentIdstringSelect a value from the drop down menu.
Namenamestring

The name of the new folder

Create If Exists?createIfExistsboolean

If the folder already exists and is not in the trash, should we create it? This option defaults to 'true' for backwards compatibility and to be consistent with default Google Drive behavior.

Authentication

Google Drive uses OAuth authentication. When you connect your Google Drive account, Pipedream will open a popup window where you can sign into Google Drive and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Google Drive API.

Pipedream requests the following authorization scopes when you connect your account:

emailprofilehttps://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/drive.readonly

About Google Drive

Internet-related services and products

More Ways to Use Google Drive

Triggers

Changes to Specific Files from the Google Drive API

Watches for changes to specific files, emitting an event any time a change is made to one of those files. To watch for changes to shared drive files, use the Changes to Specific Files (Shared Drive) source instead.

 
Try it
Changes to Specific Files (Shared Drive) from the Google Drive API

Watches for changes to specific files in a shared drive, emitting an event any time a change is made to one of those files

 
Try it
New Files (Instant) from the Google Drive API

Emit new event any time a new file is added in your linked Google Drive

 
Try it
New or Modified Comments from the Google Drive API

Emits a new event any time a file comment is added, modified, or deleted in your linked Google Drive

 
Try it
New or Modified Files from the Google Drive API

Emits a new event any time any file in your linked Google Drive is added, modified, or deleted

 
Try it

Actions

Add File Sharing Preference with the Google Drive API

Add a sharing permission to the sharing preferences of a file and provide a sharing URL. See the docs for more information

 
Try it
Copy File with the Google Drive API

Create a copy of the specified file. See the docs for more information

 
Try it
Create a New File with the Google Drive API

Create a new file from a URL or /tmp/filepath. See the docs for more information

 
Try it
Create New File From Template with the Google Drive API

Create a new google doc file from template. See documentation

 
Try it
Create New File From Text with the Google Drive API

Create a new file from plain text. See the docs for more information

 
Try it