@@ -41,38 +41,44 @@ yarn add unstructured-client --dev
41
41
```
42
42
<!-- No SDK Installation -->
43
43
44
- <!-- Start SDK Example Usage [usage] -->
45
44
## SDK Example Usage
46
45
47
46
### Example
48
47
49
48
``` typescript
50
- import { openAsBlob } from " node:fs" ;
51
49
import { UnstructuredClient } from " unstructured-client" ;
50
+ import { PartitionResponse } from " unstructured-client/sdk/models/operations" ;
52
51
import { Strategy } from " unstructured-client/sdk/models/shared" ;
52
+ import * as fs from " fs" ;
53
53
54
54
const unstructuredClient = new UnstructuredClient ({
55
55
security: {
56
56
apiKeyAuth: " YOUR_API_KEY" ,
57
57
},
58
58
});
59
59
60
- async function run() {
61
- const result = await unstructuredClient .general .partition ({
62
- partitionParameters: {
63
- files: await openAsBlob (" ./sample-file" ),
64
- strategy: Strategy .Auto ,
65
- },
66
- });
60
+ const filename = " ./sample-file" ;
61
+ const data = fs .readFileSync (filename );
67
62
68
- // Handle the result
69
- console .log (result );
70
- }
71
-
72
- run ();
63
+ unstructuredClient .general .partition ({
64
+ partitionParameters: {
65
+ files: {
66
+ content: data ,
67
+ fileName: filename ,
68
+ },
69
+ strategy: Strategy .Auto ,
70
+ }
71
+ }).then ((res : PartitionResponse ) => {
72
+ if (res .statusCode == 200 ) {
73
+ console .log (res .elements );
74
+ }
75
+ }).catch ((e ) => {
76
+ console .log (e .statusCode );
77
+ console .log (e .body );
78
+ });
73
79
74
80
```
75
- <!-- End SDK Example Usage [usage] -->
81
+ <!-- No SDK Example Usage [usage] -->
76
82
77
83
Refer to the [ API parameters page] ( https://docs.unstructured.io/api-reference/api-services/api-parameters ) for all available parameters.
78
84
0 commit comments