-
Notifications
You must be signed in to change notification settings - Fork 1
Quickstart
StefanGreve edited this page Oct 18, 2023
·
4 revisions
You can use anonpy
to interface with a wide variety of REST services by building a contract with the Endpoint
class.
from anonpy import AnonPy, Endpoint
api = "https://pixeldrain.com/api/"
endpoint = Endpoint(upload="/file", download="file/{}", preview="/file/{}/info")
anon = AnonPy(api, endpoint)
# retrieve resource meta data without committing to a download
preview = anon.preview("LNcXZ9UM")
print(f"{preview=}")
# download a resource to the current working directory
download = anon.download("LNcXZ9UM", enable_progressbar=True)
print(f"{download=}")
# upload a file
upload = anon.upload("homework.docx", enable_progressbar=True)
print(f"{upload=}")
Compute the SHA1 hash and upload the file located in path
to the configured server. Then, copy the DDL to clipboard and output the checksum.
anonpy upload --file <path> --algorithm sha1 --clip
You can pass
md4
,sha1
,sha256
, orblake2b
to the--algorithm
option.
Get the info response data for a given resource
.
anonpy --logging preview -r <resource>
Download a file defined by the resource
identifier to $home
, and overwrite the file if it already exists.
anonpy download -f -r <resource> -p $home
Add the
--checksum <hash>
option to compare the checksum of the downlaoded file using the algorithm configured inanonpy.ini
.