packages feed

hstratus-drive-0.1.0.0: README.md

# hstratus-drive — access to iCloud Drive

`hstratus-drive` browses and downloads files from iCloud Drive using an
authenticated session from [`hstratus-auth`](https://github.com/adetokunbo/hstratus/tree/main/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

```haskell
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

```haskell
downloadExample :: DriveApi -> FileData -> IO ()
downloadExample da fd = do
  bytes <- downloadFile da fd
  -- bytes :: Data.ByteString.Lazy.ByteString
  print (Data.ByteString.Lazy.length bytes)
```

### Mutating

```haskell
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`](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.