[![Python Test](https://github.com/chumicat/fileio_wrapper/actions/workflows/python-test.yml/badge.svg)](https://github.com/chumicat/fileio_wrapper/actions/workflows/python-test.yml)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/fileio-wrapper)](https://pypistats.org/packages/fileio-wrapper)
[![GitHub](https://img.shields.io/github/license/chumicat/fileio_wrapper)](LICENSE)
[![PyPI](https://img.shields.io/pypi/v/fileio-wrapper)](https://pypi.org/project/fileio-wrapper/)
# fileio-wrapper
This Python package is a wrapper for the file.io Restful API, allowing for easy 'uploading' and 'downloading' of files and retrieval of account information, such as storage usage and other relevant metrics.
## What is file.io?
File.io is a cloud storage service that allows users to easily upload files, share them via links, and automatically delete them after download or within a set time period for added security. By default, the service is configured to delete files after they have been downloaded once.
## Methods
| Method | Auth? | Restful API | fileio_wrapper |
| --- | --- | --- |---------------------------------------|
| Upload | Optional | POST / | Fileio.upload()<br>fileio.upload |
| Download | Optional | GET /{key} | Fileio.download<br>fileio.download |
| List Files | Required | GET / | fileio.list |
| Account Information | Required | GET /me | fileio.me |
| Update All | Required | PUT /{key} | fileio.update(mode='replace_all') |
| Update Parital | Required | PATCH /{key} | fileio.update(mode='replace_partial') |
| Delete | Required | DELETE /{key} | fileio.delete
## Usage
### Install the package
[PyPI Package Link](https://pypi.org/project/fileio-wrapper/)
```bash
pip install fileio-wrapper
```
### Import the package
> #### Import Example:
> ```python=
> from fileio_wrapper import Fileio
> ```
### Authentication
Some methods in this service do not require authentication, which means that you can upload or download files without needing to authenticate.
> #### Authentication Declaration:
> ```python
> Fileio(api_key)
> ```
> #### Authentication Example:
> 1. To generate your API key for file.io, go to https://www.file.io/account/apikeys
> ![](https://i.imgur.com/Ks9ZVpw.png)
> 2. To authenticate a Fileio instance, include the necessary credentials during construction
> ```python=
> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'
> fileio = Fileio(fileio_api_key)
> ```
### Upload
Uploading files to file.io is easy and can be done without authentication. However, if you authenticate with the service, you can manage your uploaded files and have access to greater storage capacity by purchasing a paid plan.
> #### Upload Declaration:
> ```python
> Fileio.upload(file[, expires][, max_downloads][, auto_delete])
> fileio.upload(file[, expires][, max_downloads][, auto_delete])
> ```
> #### Upload Parameter
> | Parameter | Description | Default Value | Free Account Limit |
> |---------------|--------------------------------------------|---------------|--------------------|
> | `file` | The filepath of the file to upload | | |
> | `expires` | The expiration date of the uploaded file | 14 days | 1 year |
> | `max_downloads` | The maximum number of times the file can be downloaded | 1 | 1 |
> | `auto_delete` | Whether to delete the file when it expires or has reached the maximum number of downloads | `True` | `True` |
>
> #### Upload Example:
> ```python=
> from datetime import datetime, timedelta
> from fileio_wrapper import Fileio
>
> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'
> filepath = './file.txt'
>
> # Uploade files without authentication
> # > The expiration date cannot be more than one year
> # > Both max downloads and auto_delete are unnecessary and cannot be changed
> Fileio.upload(filepath)
> Fileio.upload(filepath, expires="20221231T235959")
>
> # Uploade files with authentication
> fileio = Fileio(fileio_api_key)
> fileio.upload(filepath) # Default: expires='14d', max_downloads=1, auto_delete=True
> fileio.upload(filepath, expires=None) # The file never expires (requires a paid plan).
> fileio.upload(filepath, expires="10m") # Expiration time specified in a count-down format "^[1-9][\d]*[y|Q|M|w|d|h|m|s]$".
> fileio.upload(filepath, expires="20221231T235959") # Expiration time specified in ISO 8601 format.
> fileio.upload(filepath, expires=datetime(2023, 1, 1)) # Expiration time specified as a datetime object.
> fileio.upload(filepath, expires=timedelta(seconds=60000)) # Expiration time specified as a timedelta object from now.
> fileio.upload(filepath, max_downloads=None) # No limit on the number of times the file can be downloaded (requires a paid plan).
> fileio.upload(filepath, max_downloads=10) # The file can be downloaded up to 10 times (requires a paid plan).
> fileio.upload(filepath, auto_delete=True) # The file will not be automatically deleted after it expires or reaches max_downloads (requires a paid plan).
>
> # The response is a dictionary containing information about the uploaded file.
> resp = fileio.upload(filepath)
> success = resp['success'] # True if upload was successful
> status = resp['status'] # HTTP status code
> key = resp['key'] # ID of uploaded file
> link = resp['link'] # Link to file (not a direct link)
> ```
### Download
You can download the file from file.io without authentication. Notice that each file can only be downloaded once by default and will be automatically deleted afterwards, regardless of whether you authenticate or not. The maximum number of downloads allowed for a file is determined by the uploader, and can be increased with a paid account.
> #### Download Declaration:
> ```python
> Fileio.download(key[, file])
> fileio.download(key[, file])
> ```
> #### Download Parameter
> | Parameter | Description | Default |
> | --------- | ---------------------------- | ------- |
> | `key` | Identity of uploaded file | |
> | `file` | Filepath of file to download | `None` |
>
> #### Download Example:
> ```python=
> from fileio_wrapper import Fileio
>
> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'
> key = 'ZDu1og7rOkJq'
>
> # Download without Authentication
> Fileio.download(key)
>
> # Download with Authentication
> # > Assuming the uploaded file is named "original_name.txt"
> fileio = Fileio(fileio_api_key)
> fileio.downlaod(key) # Raw-Byte in key 'content'
> fileio.downlaod(key, '') # Raw-Byte in key 'content'
> fileio.download(key, "folder") # Download to ./filder/original_name.txt
> fileio.download(key, "assigned_name.txt") # Download to ./assigned_name.txt
>
> # Response is dict of downloaded file information if file parameter is assigned.
> resp = fileio.download(key, "folder")
> success = resp['success'] # True if upload was successful
> status = resp['status'] # HTTP status code
> key = resp['key'] # ID of uploaded file
> path = resp['path'] # Directory of downloaded file located
> name = resp['name'] # Filename of Downloaded file
> ```
### List Files
List File in an account. Authenticate is needed to call the method.
> #### List Declaration:
> ```python
> fileio.list([search][, sort][, offset][, limit])
> ```
>
> #### List Parameter
> | Parameter | Description | Default |
> | ------------- | -------------------------- | ------- |
> | `search` | Filter filename <br> (Can't search other field) | `None` |
> | `sort` | Sort on specific field | `None` |
> | `offset` | Return start index | `None` |
> | `limit` | Max returned item | `None` |
> #### List Example:
> ```python=
> from fileio_wrapper import Fileio
>
> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'
>
> fileio = Fileio(fileio_api_key)
>
> # List all items in the account
> fileio.list()
>
> # List items with filename containing 'txt'
> fileio.list(search='txt')
>
> # List items and sort by size
> fileio.list(sort='size')
>
> # List items starting from the fourth element
> fileio.list(offset=3)
>
> # List at most 5 items
> fileio.list(limit=5)
>
> # If the 'file' parameter is assigned, the response is a dictionary of information for the downloaded file
> resp = fileio.list()
> for item in resp['nodes']:
> key = item['key'] # Identity of the file
> link = item['link'] # Link to the file (this is not a direct link)
> name = item['name'] # Name of the file
> size = item['size'] # Size of the file in bytes
> ```
### Account Information
Retrive Account Information, such as account plan level and restriction. Authenticate is needed to call the method.
> #### Me Declaration
> ```python
> fileio.me()
> ```
>
> #### Me Example
> ```python=
> from fileio_wrapper import Fileio
>
> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'
>
> # Get account information with authentication
> fileio = Fileio(fileio_api_key)
> resp = fileio.me()
>
> # Extract account details from response
> storage_limit = resp['maxStorageBytes'] # Maximum storage limit in bytes
> storage_used = resp['usedStorageBytes'] # Amount of storage used in bytes
> can_get_direct_url = resp['directDownload'] # Whether direct download URLs are available (0 for free accounts)
> rate_limit = resp['rateLimit'] # Maximum number of API calls allowed per second
> ```
### Update
Update an uploaded file by providing its key and modifying its attributes, such as the expiration date, maximum number of downloads, or even the file itself associated with the key. Authenticate is needed to call the method.
> #### Update Declaration:
> ```python
> fileio.update(key[, file][, expires][, max_downloads][, auto_delete][, mode='replace_partial'])
> fileio.update(key, file[, expires][, max_downloads][, auto_delete], mode='replace_all')
> ```
> #### Update Parameter
> | Parameter | Description | Default Value | Free Account Limit |
> | ------------- | ------- | ------- | --- |
> | `key` | Identity of uploaded file | |
> | `file` | The filepath of the file to upload | | |
> | `expires` | The expiration date of the uploaded file | 14 days | 1 year |
> | `max_downloads` | The maximum number of times the file can be downloaded | 1 | 1 |
> | `auto_delete` | Whether to delete the file when it expires or has reached the maximum number of downloads | `True` | `True` |
> | `mode` | 'replace_partial'<br>or 'replace_all' | 'replace_partial' |
>
> #### Update Example:
> ```python=
> from datetime import datetime, timedelta
> from fileio_wrapper import Fileio
>
> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'
> filepath = './file.txt'
>
> fileio = Fileio(fileio_api_key)
>
> # Update file to another only
> fileio.update(key, file=filepath)
> fileio.update(key, file=filepath, mode='replace_partial')
>
> ## Update expiration date only
> fileio.upload(key, expires=None) # The file never expires (requires a paid plan).
> fileio.upload(key, expires="10m") # Expiration time specified in a count-down format "^[1-9][\d]*[y|Q|M|w|d|h|m|s]$".
> fileio.upload(key, expires="20221231T235959") # Expiration time specified in ISO 8601 format.
> fileio.upload(key, expires=datetime(2023, 1, 1)) # Expiration time specified as a datetime object.
> fileio.upload(key, expires=timedelta(seconds=60000)) # Expiration time specified as a timedelta object from now.
>
> ## Update max_downloads or auto_delete only
> fileio.upload(key, max_downloads=None) # No limit on the number of times the file can be downloaded (requires a paid plan).
> fileio.upload(key, max_downloads=10) # The file can be downloaded up to 10 times (requires a paid plan).
> fileio.upload(key, auto_delete=True) # The file will not be automatically deleted after it expires or reaches max_downloads (requires a paid plan).
>
> # Update all fields at once.
> # If a field is not assigned a value, the default value will be used.
> fileio.update(key, file=filepath, mode='replace_all') # Default: expires='14d', max_downloads=1, auto_delete=True
> fileio.update(key, max_download=1) # The API returned an error response. Since this mode requires updating all fields, the file parameter is mandatory.
>
> # Response is dict of uploaded file information after update
> resp = fileio.update(filepath)
> success = resp['success'] # True if upload was successful
> status = resp['status'] # HTTP status code
> key = resp['key'] # ID of uploaded file
> link = resp['link'] # Link to file (not a direct link)
> ```
### Delete
> #### Delete Declaration:
> ```python
> fileio.delete(key)
> ```
> #### Delete Parameter
> | Parameter | Description |
> | --------- | ------------------------- |
> | `key` | Identity of uploaded file |
>
> #### Delete Example
> ```python=
> from fileio_wrapper import Fileio
>
> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'
> key = 'ZDu1og7rOkJq'
>
> # Delete files with authentication
> fileio.delete(key)
> ```
## Reference
- [file.io API](https://www.file.io/developers)
- [curl converter](https://curlconverter.com/)
MIT License
Copyright (c) 2023 Chumicat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Raw data
{
"_id": null,
"home_page": "https://github.com/Chumicat/fileio_wrapper",
"name": "fileio-wrapper",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "API wrapper,upload,download,cloud storage,file.io,file-io",
"author": "Chumicat",
"author_email": "russell57260620@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/c6/47/d97b0cdf26555ba214e9c96a03a4d2146b7ec2226c0a5da5314bae7ca20a/fileio-wrapper-1.0.3.tar.gz",
"platform": null,
"description": "[![Python Test](https://github.com/chumicat/fileio_wrapper/actions/workflows/python-test.yml/badge.svg)](https://github.com/chumicat/fileio_wrapper/actions/workflows/python-test.yml)\r\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/fileio-wrapper)](https://pypistats.org/packages/fileio-wrapper)\r\n[![GitHub](https://img.shields.io/github/license/chumicat/fileio_wrapper)](LICENSE)\r\n[![PyPI](https://img.shields.io/pypi/v/fileio-wrapper)](https://pypi.org/project/fileio-wrapper/)\r\n\r\n# fileio-wrapper \r\nThis Python package is a wrapper for the file.io Restful API, allowing for easy 'uploading' and 'downloading' of files and retrieval of account information, such as storage usage and other relevant metrics.\r\n\r\n## What is file.io?\r\nFile.io is a cloud storage service that allows users to easily upload files, share them via links, and automatically delete them after download or within a set time period for added security. By default, the service is configured to delete files after they have been downloaded once.\r\n \r\n\r\n## Methods\r\n| Method | Auth? | Restful API | fileio_wrapper |\r\n| --- | --- | --- |---------------------------------------|\r\n| Upload | Optional | POST / | Fileio.upload()<br>fileio.upload |\r\n| Download | Optional | GET /{key} | Fileio.download<br>fileio.download |\r\n| List Files | Required | GET / | fileio.list |\r\n| Account Information | Required | GET /me | fileio.me |\r\n| Update All | Required | PUT /{key} | fileio.update(mode='replace_all') |\r\n| Update Parital | Required | PATCH /{key} | fileio.update(mode='replace_partial') |\r\n| Delete | Required | DELETE /{key} | fileio.delete \r\n\r\n## Usage\r\n### Install the package\r\n[PyPI Package Link](https://pypi.org/project/fileio-wrapper/)\r\n```bash\r\npip install fileio-wrapper\r\n```\r\n### Import the package\r\n> #### Import Example: \r\n> ```python=\r\n> from fileio_wrapper import Fileio\r\n> ```\r\n\r\n### Authentication\r\nSome methods in this service do not require authentication, which means that you can upload or download files without needing to authenticate.\r\n> #### Authentication Declaration: \r\n> ```python\r\n> Fileio(api_key)\r\n> ```\r\n> #### Authentication Example: \r\n> 1. To generate your API key for file.io, go to https://www.file.io/account/apikeys\r\n> ![](https://i.imgur.com/Ks9ZVpw.png)\r\n> 2. To authenticate a Fileio instance, include the necessary credentials during construction\r\n> ```python=\r\n> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'\r\n> fileio = Fileio(fileio_api_key)\r\n> ```\r\n\r\n### Upload\r\nUploading files to file.io is easy and can be done without authentication. However, if you authenticate with the service, you can manage your uploaded files and have access to greater storage capacity by purchasing a paid plan.\r\n> #### Upload Declaration: \r\n> ```python\r\n> Fileio.upload(file[, expires][, max_downloads][, auto_delete])\r\n> fileio.upload(file[, expires][, max_downloads][, auto_delete])\r\n> ```\r\n> #### Upload Parameter\r\n> | Parameter | Description | Default Value | Free Account Limit |\r\n> |---------------|--------------------------------------------|---------------|--------------------|\r\n> | `file` | The filepath of the file to upload | | |\r\n> | `expires` | The expiration date of the uploaded file | 14 days | 1 year |\r\n> | `max_downloads` | The maximum number of times the file can be downloaded | 1 | 1 |\r\n> | `auto_delete` | Whether to delete the file when it expires or has reached the maximum number of downloads | `True` | `True` |\r\n> \r\n> #### Upload Example:\r\n> ```python=\r\n> from datetime import datetime, timedelta\r\n> from fileio_wrapper import Fileio\r\n> \r\n> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'\r\n> filepath = './file.txt'\r\n> \r\n> # Uploade files without authentication\r\n> # > The expiration date cannot be more than one year\r\n> # > Both max downloads and auto_delete are unnecessary and cannot be changed\r\n> Fileio.upload(filepath)\r\n> Fileio.upload(filepath, expires=\"20221231T235959\")\r\n> \r\n> # Uploade files with authentication\r\n> fileio = Fileio(fileio_api_key)\r\n> fileio.upload(filepath) # Default: expires='14d', max_downloads=1, auto_delete=True\r\n> fileio.upload(filepath, expires=None) # The file never expires (requires a paid plan).\r\n> fileio.upload(filepath, expires=\"10m\") # Expiration time specified in a count-down format \"^[1-9][\\d]*[y|Q|M|w|d|h|m|s]$\".\r\n> fileio.upload(filepath, expires=\"20221231T235959\") # Expiration time specified in ISO 8601 format.\r\n> fileio.upload(filepath, expires=datetime(2023, 1, 1)) # Expiration time specified as a datetime object.\r\n> fileio.upload(filepath, expires=timedelta(seconds=60000)) # Expiration time specified as a timedelta object from now.\r\n> fileio.upload(filepath, max_downloads=None) # No limit on the number of times the file can be downloaded (requires a paid plan).\r\n> fileio.upload(filepath, max_downloads=10) # The file can be downloaded up to 10 times (requires a paid plan).\r\n> fileio.upload(filepath, auto_delete=True) # The file will not be automatically deleted after it expires or reaches max_downloads (requires a paid plan).\r\n> \r\n> # The response is a dictionary containing information about the uploaded file.\r\n> resp = fileio.upload(filepath)\r\n> success = resp['success'] # True if upload was successful\r\n> status = resp['status'] # HTTP status code\r\n> key = resp['key'] # ID of uploaded file\r\n> link = resp['link'] # Link to file (not a direct link)\r\n> ```\r\n\r\n### Download\r\nYou can download the file from file.io without authentication. Notice that each file can only be downloaded once by default and will be automatically deleted afterwards, regardless of whether you authenticate or not. The maximum number of downloads allowed for a file is determined by the uploader, and can be increased with a paid account.\r\n> #### Download Declaration: \r\n> ```python\r\n> Fileio.download(key[, file])\r\n> fileio.download(key[, file])\r\n> ```\r\n> #### Download Parameter\r\n> | Parameter | Description | Default |\r\n> | --------- | ---------------------------- | ------- |\r\n> | `key` | Identity of uploaded file | |\r\n> | `file` | Filepath of file to download | `None` |\r\n> \r\n> #### Download Example:\r\n> ```python=\r\n> from fileio_wrapper import Fileio\r\n> \r\n> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'\r\n> key = 'ZDu1og7rOkJq'\r\n> \r\n> # Download without Authentication\r\n> Fileio.download(key)\r\n> \r\n> # Download with Authentication\r\n> # > Assuming the uploaded file is named \"original_name.txt\"\r\n> fileio = Fileio(fileio_api_key)\r\n> fileio.downlaod(key) # Raw-Byte in key 'content'\r\n> fileio.downlaod(key, '') # Raw-Byte in key 'content'\r\n> fileio.download(key, \"folder\") # Download to ./filder/original_name.txt\r\n> fileio.download(key, \"assigned_name.txt\") # Download to ./assigned_name.txt\r\n> \r\n> # Response is dict of downloaded file information if file parameter is assigned.\r\n> resp = fileio.download(key, \"folder\")\r\n> success = resp['success'] # True if upload was successful\r\n> status = resp['status'] # HTTP status code\r\n> key = resp['key'] # ID of uploaded file\r\n> path = resp['path'] # Directory of downloaded file located\r\n> name = resp['name'] # Filename of Downloaded file\r\n> ```\r\n\r\n### List Files\r\nList File in an account. Authenticate is needed to call the method.\r\n> #### List Declaration: \r\n> ```python\r\n> fileio.list([search][, sort][, offset][, limit])\r\n> ```\r\n> \r\n> #### List Parameter\r\n> | Parameter | Description | Default |\r\n> | ------------- | -------------------------- | ------- |\r\n> | `search` | Filter filename <br> (Can't search other field) | `None` |\r\n> | `sort` | Sort on specific field | `None` |\r\n> | `offset` | Return start index | `None` |\r\n> | `limit` | Max returned item | `None` |\r\n> #### List Example:\r\n> ```python=\r\n> from fileio_wrapper import Fileio\r\n> \r\n> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'\r\n> \r\n> fileio = Fileio(fileio_api_key)\r\n> \r\n> # List all items in the account\r\n> fileio.list()\r\n> \r\n> # List items with filename containing 'txt'\r\n> fileio.list(search='txt')\r\n> \r\n> # List items and sort by size\r\n> fileio.list(sort='size')\r\n> \r\n> # List items starting from the fourth element\r\n> fileio.list(offset=3)\r\n> \r\n> # List at most 5 items\r\n> fileio.list(limit=5)\r\n> \r\n> # If the 'file' parameter is assigned, the response is a dictionary of information for the downloaded file\r\n> resp = fileio.list()\r\n> for item in resp['nodes']:\r\n> key = item['key'] # Identity of the file\r\n> link = item['link'] # Link to the file (this is not a direct link)\r\n> name = item['name'] # Name of the file\r\n> size = item['size'] # Size of the file in bytes\r\n> ```\r\n\r\n\r\n### Account Information\r\nRetrive Account Information, such as account plan level and restriction. Authenticate is needed to call the method.\r\n> #### Me Declaration\r\n> ```python\r\n> fileio.me()\r\n> ```\r\n> \r\n> #### Me Example\r\n> ```python=\r\n> from fileio_wrapper import Fileio\r\n> \r\n> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'\r\n> \r\n> # Get account information with authentication\r\n> fileio = Fileio(fileio_api_key)\r\n> resp = fileio.me()\r\n> \r\n> # Extract account details from response\r\n> storage_limit = resp['maxStorageBytes'] # Maximum storage limit in bytes\r\n> storage_used = resp['usedStorageBytes'] # Amount of storage used in bytes\r\n> can_get_direct_url = resp['directDownload'] # Whether direct download URLs are available (0 for free accounts)\r\n> rate_limit = resp['rateLimit'] # Maximum number of API calls allowed per second\r\n> ```\r\n\r\n### Update\r\nUpdate an uploaded file by providing its key and modifying its attributes, such as the expiration date, maximum number of downloads, or even the file itself associated with the key. Authenticate is needed to call the method.\r\n> #### Update Declaration: \r\n> ```python\r\n> fileio.update(key[, file][, expires][, max_downloads][, auto_delete][, mode='replace_partial'])\r\n> fileio.update(key, file[, expires][, max_downloads][, auto_delete], mode='replace_all')\r\n> ```\r\n> #### Update Parameter\r\n> | Parameter | Description | Default Value | Free Account Limit |\r\n> | ------------- | ------- | ------- | --- |\r\n> | `key` | Identity of uploaded file | |\r\n> | `file` | The filepath of the file to upload | | |\r\n> | `expires` | The expiration date of the uploaded file | 14 days | 1 year |\r\n> | `max_downloads` | The maximum number of times the file can be downloaded | 1 | 1 |\r\n> | `auto_delete` | Whether to delete the file when it expires or has reached the maximum number of downloads | `True` | `True` |\r\n> | `mode` | 'replace_partial'<br>or 'replace_all' | 'replace_partial' | \r\n> \r\n> #### Update Example:\r\n> ```python=\r\n> from datetime import datetime, timedelta\r\n> from fileio_wrapper import Fileio\r\n> \r\n> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'\r\n> filepath = './file.txt'\r\n> \r\n> fileio = Fileio(fileio_api_key)\r\n> \r\n> # Update file to another only\r\n> fileio.update(key, file=filepath)\r\n> fileio.update(key, file=filepath, mode='replace_partial')\r\n> \r\n> ## Update expiration date only\r\n> fileio.upload(key, expires=None) # The file never expires (requires a paid plan).\r\n> fileio.upload(key, expires=\"10m\") # Expiration time specified in a count-down format \"^[1-9][\\d]*[y|Q|M|w|d|h|m|s]$\".\r\n> fileio.upload(key, expires=\"20221231T235959\") # Expiration time specified in ISO 8601 format.\r\n> fileio.upload(key, expires=datetime(2023, 1, 1)) # Expiration time specified as a datetime object.\r\n> fileio.upload(key, expires=timedelta(seconds=60000)) # Expiration time specified as a timedelta object from now.\r\n> \r\n> ## Update max_downloads or auto_delete only\r\n> fileio.upload(key, max_downloads=None) # No limit on the number of times the file can be downloaded (requires a paid plan).\r\n> fileio.upload(key, max_downloads=10) # The file can be downloaded up to 10 times (requires a paid plan).\r\n> fileio.upload(key, auto_delete=True) # The file will not be automatically deleted after it expires or reaches max_downloads (requires a paid plan).\r\n> \r\n> # Update all fields at once. \r\n> # If a field is not assigned a value, the default value will be used.\r\n> fileio.update(key, file=filepath, mode='replace_all') # Default: expires='14d', max_downloads=1, auto_delete=True\r\n> fileio.update(key, max_download=1) # The API returned an error response. Since this mode requires updating all fields, the file parameter is mandatory.\r\n> \r\n> # Response is dict of uploaded file information after update\r\n> resp = fileio.update(filepath)\r\n> success = resp['success'] # True if upload was successful\r\n> status = resp['status'] # HTTP status code\r\n> key = resp['key'] # ID of uploaded file\r\n> link = resp['link'] # Link to file (not a direct link)\r\n> ```\r\n\r\n### Delete\r\n> #### Delete Declaration: \r\n> ```python\r\n> fileio.delete(key)\r\n> ```\r\n> #### Delete Parameter\r\n> | Parameter | Description |\r\n> | --------- | ------------------------- |\r\n> | `key` | Identity of uploaded file |\r\n> \r\n> #### Delete Example\r\n> ```python=\r\n> from fileio_wrapper import Fileio\r\n> \r\n> fileio_api_key = 'XXXXXXX.XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'\r\n> key = 'ZDu1og7rOkJq'\r\n> \r\n> # Delete files with authentication\r\n> fileio.delete(key)\r\n> ```\r\n\r\n## Reference\r\n- [file.io API](https://www.file.io/developers)\r\n- [curl converter](https://curlconverter.com/)\r\n\r\n\r\nMIT License\r\n\r\nCopyright (c) 2023 Chumicat\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python wrapper for the online file sharing service file.io",
"version": "1.0.3",
"project_urls": {
"Homepage": "https://github.com/Chumicat/fileio_wrapper"
},
"split_keywords": [
"api wrapper",
"upload",
"download",
"cloud storage",
"file.io",
"file-io"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3dc38f3c0e61b8f1d386f61f8e669bb1bd9a75fbbe377e01432802bc6998133e",
"md5": "bc9249702bdc176996d7378ec4969142",
"sha256": "76bbff98825c8028f5e9ba232ef7a06185c9d6d70453531be5d7e51891886cdc"
},
"downloads": -1,
"filename": "fileio_wrapper-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bc9249702bdc176996d7378ec4969142",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 10302,
"upload_time": "2023-06-28T09:15:44",
"upload_time_iso_8601": "2023-06-28T09:15:44.356413Z",
"url": "https://files.pythonhosted.org/packages/3d/c3/8f3c0e61b8f1d386f61f8e669bb1bd9a75fbbe377e01432802bc6998133e/fileio_wrapper-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c647d97b0cdf26555ba214e9c96a03a4d2146b7ec2226c0a5da5314bae7ca20a",
"md5": "90eb570202cc3ac751ba1327c1828f5d",
"sha256": "46fce8fb9ae294269b9798ea1e9a14b14231877d383e0cfee112fec9e7230366"
},
"downloads": -1,
"filename": "fileio-wrapper-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "90eb570202cc3ac751ba1327c1828f5d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 14424,
"upload_time": "2023-06-28T09:15:46",
"upload_time_iso_8601": "2023-06-28T09:15:46.310616Z",
"url": "https://files.pythonhosted.org/packages/c6/47/d97b0cdf26555ba214e9c96a03a4d2146b7ec2226c0a5da5314bae7ca20a/fileio-wrapper-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-28 09:15:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Chumicat",
"github_project": "fileio_wrapper",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": []
}
],
"lcname": "fileio-wrapper"
}