Skip to content

bluzky/gdrive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gdrive

Online document

Installation

  1. available in Hex, the package can be installed by adding gdrive to your list of dependencies in mix.exs:
def deps do
  [
    {:gdrive, "~> 0.1.0"}
  ]
end
  1. Create or select a project at Google Drive API enabler wizard. Click Continue. Click Go to credentials.

  2. Select Other non-UI > Click Application data > Click No, I have not used. > Click Required credentials.

  3. Input Service account name, Select Porject - Owner. Click next, Start download JSON automatically. Rename it to client_secret.json and move to config folder.

  4. Click Manage service accounts > Edit service account > Click Enable G Suite domain wide delegation > Save.

  5. Browse Google Drive > select any folder > share with service account id(like xxx-xxx@xxxx.iam.gserviceaccount.com).

  6. Add to your config.exs file:

config :goth,
  json: "./config/client_secret.json" |> File.read!

Usage

1. Basic usage

Gdrive wrap basic Files api with:

  • create files
  • create folder
  • list
  • get files
  • upload files
  • update, copy, delete file/folder
{status, file_info} = Gdrive.upload("/user/my_folder/file.txt", name: "first-file.txt")

2. Advance

You can make a request with Gdrive.Api.File which support all params

# grab google token
{_, token} = Goth.Token.for_scope("https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/drive.file,https://www.googleapis.com/auth/drive.appdata")
# init new connection
connection = Connection.new(token)

# send request
{status, data} = Gdrive.Api.File.create(connection, name: "empty.txt", mimeType: "text/plain")

Online document

About

Upload and manage file on google drive in elixir

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages