File repository API Client
Project description
file-repository-api-client
A small api client library used with a file repository Api.
Installation
pip install file-repository-api-client
Save file to File Repository API
from file_repository_api_client import FileApi
url: str = "https://file.example.api.com/files"
file: str = "~/my_file.txt"
api = FileApi(url)
resp: dict = api.store_file(file)
#get file guid
print(resp["results"]["guid"])
Retrieve file from File Repository API
Send file to repository API for storage:
import requests
from file_repository_api_client import FileApi
url: str = "https://file.example.api.com/files"
guid: str = "bd353120-e0ed-4400-83f1-9eba80db2809"
api = FileApi(url)
resp: dict = api.retrieve_file(guid)
#specify local file name
file_name: str = f"{resp['results']['name']}"
try:
response = requests.get(resp["results"]["presigned_url"], allow_redirects=True)
response.raise_for_status()
with open(file_name, mode="w", encoding="utf-8") as f:
f.write(response.content.decode("utf-8"))
except requests.exceptions.HTTPError as err:
print(f"Exception occurred whilst attempting download file from api, error: {err}")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file file-repository-api-client-0.1.0.tar.gz
.
File metadata
- Download URL: file-repository-api-client-0.1.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa30f09fb4353cca95b9842099238f9f6f2bdbba601c297f8a58235c9541652e |
|
MD5 | a0a32808d54731cf203825225385ed98 |
|
BLAKE2b-256 | 9621688a1de6e0130844ef2d95a309d00a039b05aaeb369f4875e497641d51ee |
File details
Details for the file file_repository_api_client-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: file_repository_api_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0eb39e223b60bc2d39f493f31813bbce5ef0c736e38f7b112760fda0cab20944 |
|
MD5 | ef5cd98cffc900054b8e340892c1e9e9 |
|
BLAKE2b-256 | c7cb6b49e4c3b92d472350741afb61e74115b4f249cf72dce1c12bd7e0ec1047 |