packages feed

hstratus-drive-0.1.2.0 / README.md

# hstratus-drive — access to iCloud Drive`hstratus-drive` browses, downloads, and mutates files in iCloud Drive using anauthenticated session from [`hstratus-auth`](https://github.com/adetokunbo/hstratus/tree/main/hstratus-auth/).The library provides access to the main CloudDocs tree: fetching the rootfolder, listing folder contents, downloading files, and mutating the tree(create, rename, delete, upload).## Disclaimer — use at your own risk- This library is **unofficial** and not supported by Apple.- The iCloud Drive API it uses is undocumented and may change without notice.## UsageAfter a successful login with `hstratus-auth`, construct a `DriveApi` value anduse it to browse, download, or mutate files.### Browsing```haskellimport Network.HStratus.Http (mkApi, login, AuthState (..))import Network.HStratus.Http.Endpoints (Realm (..))import Network.HStratus.Driveexample :: IO ()example = do  api <- mkApi Usual  result <- login api  case result of    Authenticated sess ad -> do      da    <- mkDriveApi ad sess api      root  <- driveRoot da      nodes <- listFolder da (fnId root)      mapM_ print nodes    _ -> putStrLn "Unexpected result"```### Downloading```haskelldownloadExample :: DriveApi -> FileData -> IO ()downloadExample da fd = do  bytes <- downloadFile da fd  -- bytes :: Data.ByteString.Lazy.ByteString  print (Data.ByteString.Lazy.length bytes)```### Mutating```haskellmutationExample :: DriveApi -> FolderData -> IO ()mutationExample da folder = do  createFolder da (fnId folder) "New Folder"  -- renameNode, deleteNode, and uploadFile follow the same pattern```## CLI usageA command-line interface using this behaviour is provided by the [`hstratus`](https://github.com/adetokunbo/hstratus/tree/main/hstratus/#readme)package.  Use [`hstratus drive ls`](https://github.com/adetokunbo/hstratus/tree/main/hstratus/#hstratus-drive-ls) to list Drive contents and[`hstratus drive cp`](https://github.com/adetokunbo/hstratus/tree/main/hstratus/#hstratus-drive-cp) to download files.---Apple and the Apple logo are trademarks of Apple Inc., registered in the U.S. and other countries and regions.iCloud is a service mark of Apple Inc., registered in the U.S. and other countries and regions.