# `GraphApi.Files`
[🔗](https://github.com/keenmate/microsoft_graph/blob/v1.0.0-rc.1/lib/graph_api/resources/files.ex#L1)

Operations on OneDrive/SharePoint files (`/drives`, `/drive/items`, etc.).

## Examples

    {:ok, drive} = GraphApi.Files.get_drive("user-id")
    {:ok, %{"value" => items}} = GraphApi.Files.list_root_children("drive-id")
    {:ok, content} = GraphApi.Files.download_content("drive-id", "item-id")

# `add_permission`

```elixir
@spec add_permission(String.t(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Invites recipients and adds permissions to a drive item.

# `add_permission_query`

```elixir
@spec add_permission_query(String.t(), String.t(), map(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `add_permission/4`.

# `copy_item`

```elixir
@spec copy_item(String.t(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Copies a drive item to a new location. Returns 202 Accepted with an async monitor URL.

# `copy_item_query`

```elixir
@spec copy_item_query(String.t(), String.t(), map(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `copy_item/4`.

# `create_folder`

```elixir
@spec create_folder(String.t(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Creates a new folder under the given parent item.

# `create_folder_query`

```elixir
@spec create_folder_query(String.t(), String.t(), map(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `create_folder/4`.

# `create_sharing_link`

```elixir
@spec create_sharing_link(String.t(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Creates a sharing link for a drive item.

# `create_sharing_link_query`

```elixir
@spec create_sharing_link_query(String.t(), String.t(), map(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `create_sharing_link/4`.

# `create_upload_session`

```elixir
@spec create_upload_session(String.t(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Creates an upload session for large file uploads (> 4 MB).

Returns the upload URL to use for uploading file chunks.

# `create_upload_session_query`

```elixir
@spec create_upload_session_query(String.t(), String.t(), map(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `create_upload_session/4`.

# `delete_item`

```elixir
@spec delete_item(String.t(), String.t(), keyword()) :: :ok | {:error, term()}
```

Deletes a drive item.

# `delete_item_query`

```elixir
@spec delete_item_query(String.t(), String.t(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `delete_item/3`.

# `delete_permission`

```elixir
@spec delete_permission(String.t(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Deletes a permission from a drive item.

# `delete_permission_query`

```elixir
@spec delete_permission_query(String.t(), String.t(), String.t(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `delete_permission/4`.

# `download_content`

```elixir
@spec download_content(String.t(), String.t(), keyword()) ::
  {:ok, binary()} | {:error, term()}
```

Downloads the content of a drive item.

Returns `{:ok, binary}` with the raw file content.

# `download_content_query`

```elixir
@spec download_content_query(String.t(), String.t(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `download_content/3`.

# `drive_delta`

```elixir
@spec drive_delta(
  String.t(),
  keyword()
) :: {:ok, GraphApi.Delta.delta_page()} | {:error, term()}
```

Delta query for a drive's root folder. Returns file/folder changes since the last sync.

# `drive_delta_query`

```elixir
@spec drive_delta_query(
  String.t(),
  keyword()
) :: GraphApi.Batch.Request.t()
```

Batch query variant of `drive_delta/2`.

# `get_drive`

```elixir
@spec get_drive(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}
```

Gets a user's default drive.

# `get_drive_query`

```elixir
@spec get_drive_query(
  String.t(),
  keyword()
) :: GraphApi.Batch.Request.t()
```

Batch query variant of `get_drive/2`.

# `get_item`

```elixir
@spec get_item(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, term()}
```

Gets a drive item by ID.

# `get_item_by_path`

```elixir
@spec get_item_by_path(String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Gets a drive item by path.

The path should be relative to the root (e.g., "Documents/report.docx").

# `get_item_by_path_query`

```elixir
@spec get_item_by_path_query(String.t(), String.t(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `get_item_by_path/3`.

# `get_item_query`

```elixir
@spec get_item_query(String.t(), String.t(), keyword()) :: GraphApi.Batch.Request.t()
```

Batch query variant of `get_item/3`.

# `get_shared_item`

```elixir
@spec get_shared_item(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}
```

Gets a shared drive item by its sharing token or encoded sharing URL.

# `get_shared_item_query`

```elixir
@spec get_shared_item_query(
  String.t(),
  keyword()
) :: GraphApi.Batch.Request.t()
```

Batch query variant of `get_shared_item/2`.

# `get_special_folder`

```elixir
@spec get_special_folder(String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Gets a special folder (e.g., "documents", "photos", "approot") in a drive.

# `get_special_folder_query`

```elixir
@spec get_special_folder_query(String.t(), String.t(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `get_special_folder/3`.

# `list_children`

```elixir
@spec list_children(String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Lists children of a specific item in a drive.

# `list_children_query`

```elixir
@spec list_children_query(String.t(), String.t(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `list_children/3`.

# `list_drives`

```elixir
@spec list_drives(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}
```

Lists all drives available to a user.

# `list_drives_query`

```elixir
@spec list_drives_query(
  String.t(),
  keyword()
) :: GraphApi.Batch.Request.t()
```

Batch query variant of `list_drives/2`.

# `list_permissions`

```elixir
@spec list_permissions(String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Lists permissions on a drive item.

# `list_permissions_query`

```elixir
@spec list_permissions_query(String.t(), String.t(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `list_permissions/3`.

# `list_root_children`

```elixir
@spec list_root_children(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}
```

Lists children of the root folder in a drive.

# `list_root_children_query`

```elixir
@spec list_root_children_query(
  String.t(),
  keyword()
) :: GraphApi.Batch.Request.t()
```

Batch query variant of `list_root_children/2`.

# `list_thumbnails`

```elixir
@spec list_thumbnails(String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Lists thumbnails for a drive item.

# `list_thumbnails_query`

```elixir
@spec list_thumbnails_query(String.t(), String.t(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `list_thumbnails/3`.

# `list_versions`

```elixir
@spec list_versions(String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Lists versions of a drive item.

# `list_versions_query`

```elixir
@spec list_versions_query(String.t(), String.t(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `list_versions/3`.

# `search`

```elixir
@spec search(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, term()}
```

Searches for items in a drive matching the given query string.

# `search_query`

```elixir
@spec search_query(String.t(), String.t(), keyword()) :: GraphApi.Batch.Request.t()
```

Batch query variant of `search/3`.

# `update_item`

```elixir
@spec update_item(String.t(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Updates a drive item's metadata (name, description, etc.).

# `update_item_query`

```elixir
@spec update_item_query(String.t(), String.t(), map(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `update_item/4`.

# `upload_small`

```elixir
@spec upload_small(String.t(), String.t(), binary(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Uploads a small file (up to 4 MB) to a drive.

For larger files, use `create_upload_session/4`.

# `upload_small_query`

```elixir
@spec upload_small_query(String.t(), String.t(), binary(), keyword()) ::
  GraphApi.Batch.Request.t()
```

Batch query variant of `upload_small/4`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
