Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-gdrive

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-gdrive

Google Drive API wrapper for Vue 2.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

VueGDrive

Overview

Google Drive API wrapper for Vue 2.

Installation

Step 1

$ yarn add uuki/vue-gapi
$ yarn add uuki/vue-gdrive

Step 2

Use VueGAPI for GAPI authentication.

import Vue from 'vue'
import VueGAPI from 'vue-gapi'
import VueGDrive from 'vue-gdrive'

/**
 * https://github.com/cedpoilly/vue-gapi
 */
Vue.use(VueGAPI, {
  apiKey: '<API_KEY>',
  clientId: '<CLIENT_ID>',
  discoveryDocs: ['<DISCOVERY_DOCS>'],
  scope: '<SCOPE>',
})
Vue.use(VueGDrive)

Methods

  • $gdrive.createFile(gapi.client.drive.files.create
  • $gdrive.deleteFile(gapi.client.drive.files.delete
  • $gdrive.getFiles(gapi.client.drive.files.list

Usage

<script>
  export default {
    methods: {
      async createFile () {
        const result = await this.$gdrive.createFile({
          name: '<FILE_NAME>',
          parents: ['<FOLDER_ID>'],
          uploadType: 'media',
          fields: 'id, name, parents',
          media: {
            mimeType: '<MIME_TYPE>'
          },
          resource: {
            mimeType: 'application/vnd.google-apps.<FILE_TYPE>'
          }
        })
      },
      async getListFiles () {
        const result = await this.$gdrive.getListFiles({
          orderBy: 'folder,modifiedTime',
          q: "trashed=false and '<DRIVE_ID>' in parents",
          fields: 'files(id, name, kind, size, mimeType, lastModifyingUser, modifiedTime, iconLink, owners, folderColorRgb, shared, webViewLink, webContentLink), nextPageToken',
        });
      },
      async deleteFile () {
        const result = await this.$gdrive.deleteFile({
          fileId: '<FILE_ID>'
        })
      },
    }
  }
</script>

Directives

  • v-gd-upload-area

※ require scope -> https://www.googleapis.com/auth/drive

Usage

Supports multiple attribute.

<template>
  <div>
    <!-- input pattern -->
    <input type="file" multiple v-gd-upload-area="uploadArea">

    <!-- droppable pattern -->
    <div v-gd-upload-area="uploadArea" />
  </div>
</template>

<script>
  export default {
    data () {
      uploadArea: {
        uploadOptions: {
          path: '/upload/drive/v3/files',
        },
        metaExtends: {
          parents:['<TARGET_FOLDER_ID>']
        },
        callback: this.onUploaded
      }
    },
    onUploaded (objFile) {
      console.log(objFile);
    }
  }
</script>

Keywords

FAQs

Package last updated on 18 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc