# CurlGoogle
[![PyPI](https://img.shields.io/pypi/v/curlgoogle.svg?color=green)](https://pypi.org/project/curlgoogle/)
CurlGoogle is a lightweight, easy-to-use, and extremely simple library that allows you to link devices to Google accounts and transfer files (upload/download) using nothing more than the command line. Built on the principles demonstrated in [this article](https://towardsdatascience.com/uploading-files-to-google-drive-directly-from-the-terminal-using-curl-2b89db28bb06), this library offers a lean alternative to more extensive libraries such as [google-drive](https://pypi.org/project/google-drive/).
With absolutely no specific dependencies needed apart from curl, you can get up and running with file transfers on Google Drive in no time. The library's minimalistic design makes it not only easy to install but also to understand and use.
## Installation
To install the library, open your terminal and type the following command:
```bash
pip install curlgoogle
```
This command installs the library from the source directory (TODO: add to PyPI).
## Usage
(Disclaimer: Most of the explanation here is derived from [this article](https://towardsdatascience.com/uploading-files-to-google-drive-directly-from-the-terminal-using-curl-2b89db28bb06).)
### Installing curl
You should install curl on the device you are trying to run this package (this is the only dependency).
```bash
sudo apt install curl # Linux Debian/Ubuntu
brew install curl # Mac
```
### Creating a Google Cloud Platform Project and Acquiring Credentials
In order to manage access to our Google Drive, we need to establish a level of control. This can be achieved by creating a project that incorporates user-specified permissions. This project will function as an intermediary between our users (or us, when using a different machine) and our Google account. The initial step in this process is to navigate to the [specified page](https://console.developers.google.com/apis/credentials?pli=1) and set up a new project.
Now, select the **Credentials** tab and then create credentials which is **OAuth Client ID** in particular. For app type, you may select anything!
After setting up, you now have a client ID and a client secret. You will need these to authenticate your requests. To automate the process, we use [Dotenv] to store your secrets. Make sure to add `.env` in your `.gitignore` file to avoid sharing your secrets with the world!
Run the following commands to install dotenv and create a `.env` file with the appropriate variables:
```bash
pip install python-dotenv
dotenv set GDRIVE_CLIENT_ID <your_client_id>
dotenv set GDRIVE_CLIENT_SECRET <your_client_secret>
```
### Upload and Download
After the setup phase, you're good to go! You do not need to repeat this phase again for your project as the credentials are safely stored in your `.env` file and the library automatically loads them when you import it.
You can use either a commandline interface (CLI) to upload/download files, or use the library sdk.
**important node**: You should extract the file or folder identifiers from their corresponding link.
#### CLI
Use the following format for download and upload
```bash
curlgoogle_upload <file/folder-1> <file/folder-2> ... <file/folder-N> (optional)<folder_id>
```
This will upload all your files or folders into a folder with the specified identifier.
You can also pick a bunch of folders or files, zip them into a single file with a specific name and then upload them all at once using the following convention:
```bash
curlgoogle_upload <file/folder-1> <file/folder-2> ... <file/folder-N> (optional)<folder_id> -m -n <zip_file_name>
```
For download use the following format:
```bash
curlgoogle_download <file_id1> <file_id2> ... <file_idN>
```
This will automatically download the files and extract them.
### SDK
You can also use the following functions for upload and download while development. Note that this will automatically prompt you to authenticate your Google account mid-run; therefore, it might not be the ideal use case for production.
```python
# Uplaoding function
curlgoogle.upload(
file_name: str,
file_list: List[str],
folder_id: Optional[str] = None
)
# Downloading function
curlgoogle.download(
file_id: str
)
```
## License
This project is licensed under [MIT License](./LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/HamidrezaKmK/curlgoogle",
"name": "curlgoogle",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "Google drive,Cloud storage,Google drive API",
"author": "Hamid Kamkari",
"author_email": "hamidrezakamkari@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/be/72/5b02e7ec0c6d4561ed81bda4a95a12f0acb21a48d04f9943d1f889570baa/curlgoogle-0.0.3.tar.gz",
"platform": null,
"description": "# CurlGoogle\n[![PyPI](https://img.shields.io/pypi/v/curlgoogle.svg?color=green)](https://pypi.org/project/curlgoogle/)\n\nCurlGoogle is a lightweight, easy-to-use, and extremely simple library that allows you to link devices to Google accounts and transfer files (upload/download) using nothing more than the command line. Built on the principles demonstrated in [this article](https://towardsdatascience.com/uploading-files-to-google-drive-directly-from-the-terminal-using-curl-2b89db28bb06), this library offers a lean alternative to more extensive libraries such as [google-drive](https://pypi.org/project/google-drive/). \n\nWith absolutely no specific dependencies needed apart from curl, you can get up and running with file transfers on Google Drive in no time. The library's minimalistic design makes it not only easy to install but also to understand and use.\n\n## Installation\nTo install the library, open your terminal and type the following command:\n\n```bash\npip install curlgoogle\n```\nThis command installs the library from the source directory (TODO: add to PyPI).\n\n## Usage\n\n(Disclaimer: Most of the explanation here is derived from [this article](https://towardsdatascience.com/uploading-files-to-google-drive-directly-from-the-terminal-using-curl-2b89db28bb06).)\n\n### Installing curl\n\nYou should install curl on the device you are trying to run this package (this is the only dependency).\n```bash\nsudo apt install curl # Linux Debian/Ubuntu\nbrew install curl # Mac\n```\n### Creating a Google Cloud Platform Project and Acquiring Credentials\nIn order to manage access to our Google Drive, we need to establish a level of control. This can be achieved by creating a project that incorporates user-specified permissions. This project will function as an intermediary between our users (or us, when using a different machine) and our Google account. The initial step in this process is to navigate to the [specified page](https://console.developers.google.com/apis/credentials?pli=1) and set up a new project.\n\nNow, select the **Credentials** tab and then create credentials which is **OAuth Client ID** in particular. For app type, you may select anything! \n\nAfter setting up, you now have a client ID and a client secret. You will need these to authenticate your requests. To automate the process, we use [Dotenv] to store your secrets. Make sure to add `.env` in your `.gitignore` file to avoid sharing your secrets with the world!\n\nRun the following commands to install dotenv and create a `.env` file with the appropriate variables:\n\n```bash\npip install python-dotenv\ndotenv set GDRIVE_CLIENT_ID <your_client_id>\ndotenv set GDRIVE_CLIENT_SECRET <your_client_secret>\n```\n\n### Upload and Download\n\nAfter the setup phase, you're good to go! You do not need to repeat this phase again for your project as the credentials are safely stored in your `.env` file and the library automatically loads them when you import it.\n\nYou can use either a commandline interface (CLI) to upload/download files, or use the library sdk. \n\n**important node**: You should extract the file or folder identifiers from their corresponding link.\n\n#### CLI\n\nUse the following format for download and upload\n```bash\ncurlgoogle_upload <file/folder-1> <file/folder-2> ... <file/folder-N> (optional)<folder_id>\n```\nThis will upload all your files or folders into a folder with the specified identifier.\n\nYou can also pick a bunch of folders or files, zip them into a single file with a specific name and then upload them all at once using the following convention:\n\n```bash\ncurlgoogle_upload <file/folder-1> <file/folder-2> ... <file/folder-N> (optional)<folder_id> -m -n <zip_file_name>\n```\n\nFor download use the following format:\n```bash\ncurlgoogle_download <file_id1> <file_id2> ... <file_idN>\n```\nThis will automatically download the files and extract them.\n\n### SDK\n\nYou can also use the following functions for upload and download while development. Note that this will automatically prompt you to authenticate your Google account mid-run; therefore, it might not be the ideal use case for production.\n\n```python\n# Uplaoding function\ncurlgoogle.upload(\n file_name: str, \n file_list: List[str], \n folder_id: Optional[str] = None\n)\n# Downloading function\ncurlgoogle.download(\n file_id: str\n)\n```\n\n## License\nThis project is licensed under [MIT License](./LICENSE).\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A simple lightweight python package for curl-based requests to google drive.",
"version": "0.0.3",
"project_urls": {
"Homepage": "https://github.com/HamidrezaKmK/curlgoogle"
},
"split_keywords": [
"google drive",
"cloud storage",
"google drive api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e188f614c598ada48681039f9d83112ccc691d56d16ce475dbcf84c2d9f50c7b",
"md5": "1694f5e831bc6add536d4792d1bd0521",
"sha256": "99147411b50257a272bbc2f0084a0a85c0030712f7f96b54796a7487184c57fe"
},
"downloads": -1,
"filename": "curlgoogle-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1694f5e831bc6add536d4792d1bd0521",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8779,
"upload_time": "2023-08-02T19:47:46",
"upload_time_iso_8601": "2023-08-02T19:47:46.576531Z",
"url": "https://files.pythonhosted.org/packages/e1/88/f614c598ada48681039f9d83112ccc691d56d16ce475dbcf84c2d9f50c7b/curlgoogle-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "be725b02e7ec0c6d4561ed81bda4a95a12f0acb21a48d04f9943d1f889570baa",
"md5": "06df5ef0e892dec3ffddb4ee6719a01c",
"sha256": "de2ec58b8a96bde1bca2a47e14d524b30367f213bc7fd7068b0ed04fffb5c487"
},
"downloads": -1,
"filename": "curlgoogle-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "06df5ef0e892dec3ffddb4ee6719a01c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8027,
"upload_time": "2023-08-02T19:47:47",
"upload_time_iso_8601": "2023-08-02T19:47:47.747658Z",
"url": "https://files.pythonhosted.org/packages/be/72/5b02e7ec0c6d4561ed81bda4a95a12f0acb21a48d04f9943d1f889570baa/curlgoogle-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-02 19:47:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "HamidrezaKmK",
"github_project": "curlgoogle",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": []
},
{
"name": "argparse",
"specs": []
},
{
"name": "python-dotenv",
"specs": []
}
],
"lcname": "curlgoogle"
}