Advertisement
akupriyanovhse

Untitled

Feb 13th, 2025
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. import yadisk
  2.  
  3. client = yadisk.Client(token="<token>")
  4.  
  5. with client:
  6.     # Check if the token is valid
  7.     print(client.check_token())
  8.  
  9.     # Get disk information
  10.     print(client.get_disk_info())
  11.  
  12.     # Print files and directories at "/some/path"
  13.     print(list(client.listdir("/some/path")))
  14.  
  15.     # Upload "file_to_upload.txt" to "/destination.txt"
  16.     client.upload("file_to_upload.txt", "/destination.txt")
  17.  
  18.     # Same thing
  19.     with open("file_to_upload.txt", "rb") as f:
  20.         client.upload(f, "/destination.txt")
  21.  
  22.     # Download "/some-file-to-download.txt" to "downloaded.txt"
  23.     client.download("/some-file-to-download.txt", "downloaded.txt")
  24.  
  25.     # Permanently remove "/file-to-remove"
  26.     client.remove("/file-to-remove", permanently=True)
  27.  
  28.     # Create a new directory at "/test-dir"
  29.     print(client.mkdir("/test-dir"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement