Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import yadisk
- client = yadisk.Client(token="<token>")
- with client:
- # Check if the token is valid
- print(client.check_token())
- # Get disk information
- print(client.get_disk_info())
- # Print files and directories at "/some/path"
- print(list(client.listdir("/some/path")))
- # Upload "file_to_upload.txt" to "/destination.txt"
- client.upload("file_to_upload.txt", "/destination.txt")
- # Same thing
- with open("file_to_upload.txt", "rb") as f:
- client.upload(f, "/destination.txt")
- # Download "/some-file-to-download.txt" to "downloaded.txt"
- client.download("/some-file-to-download.txt", "downloaded.txt")
- # Permanently remove "/file-to-remove"
- client.remove("/file-to-remove", permanently=True)
- # Create a new directory at "/test-dir"
- print(client.mkdir("/test-dir"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement