Skip to main content

Format Media Storage

Use formatStorage to delete every photo, video, and audio recording stored on a connected device. Despite its name, this API delegates to the existing delete-all-media operation; it does not issue a separate filesystem-format command.

:::danger Destructive operation

This action removes all device media and is not presented as recoverable by the SDK. Require explicit user confirmation before starting it.

:::

Prerequisites

  • Wait until the device is connected and ready.
  • Stop recording and finish or cancel active media imports.
  • Disable repeated submission while the operation is in progress.

Implement with AI Assistance

Build with AI

Implement this workflow with AI

Use the official Implement AIBuds Storage Formatting skill to adapt this workflow to your app.

Read and follow https://docs-aibuds.github.io/skills/implement-aibuds-format-storage. Use it to implement Implement AIBuds Storage Formatting in this iOS project and verify the result.
View official skill

API Behavior

The completion callback reports whether the underlying delete-all request was accepted. It does not return refreshed media counts or storage information.

Usage Example

Swift
import AIBuds

func formatMediaStorage(on device: DeviceConvertible) {
    guard let device = device as? DeviceCommonAPI else {
        print("This device does not support common operations")
        return
    }

    device.formatStorage { success, error in
        DispatchQueue.main.async {
            if success {
                print("All device media was deleted")
            } else {
                print("Delete failed: \(error?.localizedDescription ?? "Unknown error")")
            }
        }
    }
}

Result Handling

  • On success, refresh the UI with Query Media Count and Query Storage Information.
  • On failure, preserve the returned error for diagnostics and allow retry only after the current request finishes.
  • If the device disconnects before completion, treat the result as indeterminate until device state is queried again.