This commit is contained in:
20
docs/snippets/swift/api/batch_extract_files_sync.md
Normal file
20
docs/snippets/swift/api/batch_extract_files_sync.md
Normal file
@@ -0,0 +1,20 @@
|
||||
```swift title="Swift"
|
||||
import Foundation
|
||||
import Kreuzberg
|
||||
import RustBridge
|
||||
|
||||
// `BatchFileItem` is an opaque swift-bridge class with no public Swift
|
||||
// constructor — build items from JSON via `batchFileItemFromJson`.
|
||||
let items = RustVec<BatchFileItem>()
|
||||
for path in ["doc1.pdf", "doc2.docx", "report.pdf"] {
|
||||
let json = "{\"path\": \"\(path)\"}"
|
||||
items.push(value: try batchFileItemFromJson(json))
|
||||
}
|
||||
|
||||
let config = try extractionConfigFromJson("{}")
|
||||
let results = try batchExtractFilesSync(items, config)
|
||||
|
||||
for (index, result) in results.enumerated() {
|
||||
print("File \(index): \(result.content().toString().count) chars")
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user