{"id":24995968,"url":"https://github.com/fclairamb/afero-gdrive","last_synced_at":"2025-04-12T04:34:01.888Z","repository":{"id":37315871,"uuid":"314694019","full_name":"fclairamb/afero-gdrive","owner":"fclairamb","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-05T18:27:24.000Z","size":3759,"stargazers_count":3,"open_issues_count":8,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T05:48:19.493Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fclairamb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-20T23:34:15.000Z","updated_at":"2025-04-05T14:41:58.000Z","dependencies_parsed_at":"2024-03-22T00:25:37.544Z","dependency_job_id":"93685951-ae9f-4ca5-b9d8-8459b85fc3bd","html_url":"https://github.com/fclairamb/afero-gdrive","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclairamb%2Fafero-gdrive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclairamb%2Fafero-gdrive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclairamb%2Fafero-gdrive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclairamb%2Fafero-gdrive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fclairamb","download_url":"https://codeload.github.com/fclairamb/afero-gdrive/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248517574,"owners_count":21117482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T15:53:07.037Z","updated_at":"2025-04-12T04:34:01.859Z","avatar_url":"https://github.com/fclairamb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Afero Google Drive Driver\n\n![Build](https://github.com/fclairamb/afero-gdrive/workflows/Build/badge.svg)\n[![codecov](https://codecov.io/gh/fclairamb/afero-gdrive/branch/main/graph/badge.svg?token=ZPOTDLRY7Y)](https://codecov.io/gh/fclairamb/afero-gdrive)\n[![Go Report Card](https://goreportcard.com/badge/fclairamb/afero-gdrive)](https://goreportcard.com/report/fclairamb/afero-gdrive)\n[![GoDoc](https://godoc.org/github.com/fclairamb/afero-gdrive?status.svg)](https://godoc.org/github.com/fclairamb/afero-gdrive)\n\n## About\nIt provides an [afero filesystem](https://github.com/spf13/afero/) implementation of a [Google Drive](https://developers.google.com/drive) backend.\n\nThis was created to provide a backend to the [ftpserver](https://github.com/fclairamb/ftpserver) but can definitely be used in any other code.\n\nI'm very opened to any improvement through issues or pull-request that might lead to a better implementation or even better testing.\n\n## Key points\n- Download \u0026 upload file streaming\n- 60% coverage: This isn't great, I intend to improve it to reach 80%. As it's a third-party API more would take way too much time.\n- Very carefully linted\n\n\n## Known limitations\n- File appending / seeking for write is not supported because Google Drive doesn't support it, it could be simulated by rewriting entire files.\n- Chmod is saved as a property and not used at this time.\n- No files listing cache. This means that every directory of a path results in a request that happens every single time a path is analyzed. In other word opening `/a/b/c/file.txt` for writing will create at least 4 request, and the same will happen for reading.\n\n## How to use\nNote: Errors handling is skipped for brevity but you definitely have to handle it.\n```golang\nimport (\n\t\"github.com/fclairamb/afero-gdrive/oauthhelper\"\n)\n\nfunc main() {\n  // We declare the OAuh2 app\n  helper := oauthhelper.Auth{\n    ClientID:     os.Getenv(\"GOOGLE_CLIENT_ID\"),\n    ClientSecret: os.Getenv(\"GOOGLE_CLIENT_SECRET\"),\n    Authenticate: func(url string) (string, error) {\n     return \"\", ErrNotSupported\n    },\n  }\n\n  // Pass a token \n  token, _ := base64.StdEncoding.DecodeString(os.Getenv(\"GOOGLE_TOKEN\"))\n  helper.Token = new(oauth2.Token)\n  json.Unmarshal(token, helper.Token)\n\t\n  // Initialize the authenticated client\n  client, _ := helper.NewHTTPClient(context.Background())\n  \n  // Initialize the FS from the athenticated http client\n  fs, _ := New(client)\n\n  // And use it\n  file, _ := fs.OpenFile(\"my_file.txt\", os.O_WRONLY, 0777)\n  file.WriteString(\"Hello world !\")\n  file.Close()\n}\n```\n\n## How to run the tests\nFollow [these instructions](https://github.com/fclairamb/afero-gdrive/tree/main/testenvhelper).\n    \n## Credits\nThis is a fork from [T4cC0re/gdriver](https://github.com/T4cC0re/gdriver) which is itself a fork of [eun/gdriver](https://github.com/eun/gdriver).\n\nThe code was massively modified. Most of the changes are improvements. The file listing API from the original implemented based on callbacks is much better though,  but this was needed to respect the afero API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffclairamb%2Fafero-gdrive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffclairamb%2Fafero-gdrive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffclairamb%2Fafero-gdrive/lists"}