About

Metadata

  • Last updated , by adetokunbo
  • License BSD-3-Clause
  • Categories Network Development
  • Maintained by: Tim Emiola <adetokunbo@emio.la>

  • Lottery factor: 1

Links

Installation

Tested Compilers

  1. 9.12.1
  2. 9.10.2
  3. 9.8.4
  4. 9.6.7
  5. 9.4.8
  6. 9.2.8

Readme

hstratus-drive — access to iCloud Drive

hstratus-drive browses and downloads files from iCloud Drive using an authenticated session from hstratus-auth.

Provides access to the main CloudDocs tree: fetching the root folder, 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.

Usage

After a successful login with hstratus-auth, construct a DriveApi value and use it to browse or download files.

Browsing
import Network.HStratus.Http (mkApi, login, AuthState (..))
import Network.HStratus.Http.Endpoints (Realm (..))
import Network.HStratus.Drive

example :: 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
downloadExample :: DriveApi -> FileData -> IO ()
downloadExample da fd = do
  bytes <- downloadFile da fd
  -- bytes :: Data.ByteString.Lazy.ByteString
  print (Data.ByteString.Lazy.length bytes)
Mutating
mutationExample :: DriveApi -> FolderData -> IO ()
mutationExample da folder = do
  createFolder da (fnId folder) "New Folder"
  -- renameNode, deleteNode, and uploadFile follow the same pattern

CLI usage

A command-line interface using this behaviour is provided by the hstratus package. Use hstratus drive ls to list Drive contents and 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.