@@ -41,38 +41,44 @@ yarn add unstructured-client --dev
4141```
4242<!-- No SDK Installation -->
4343
44- <!-- Start SDK Example Usage [usage] -->
4544## SDK Example Usage
4645
4746### Example
4847
4948``` typescript
50- import { openAsBlob } from " node:fs" ;
5149import { UnstructuredClient } from " unstructured-client" ;
50+ import { PartitionResponse } from " unstructured-client/sdk/models/operations" ;
5251import { Strategy } from " unstructured-client/sdk/models/shared" ;
52+ import * as fs from " fs" ;
5353
5454const unstructuredClient = new UnstructuredClient ({
5555 security: {
5656 apiKeyAuth: " YOUR_API_KEY" ,
5757 },
5858});
5959
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 );
6762
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+ });
7379
7480```
75- <!-- End SDK Example Usage [usage] -->
81+ <!-- No SDK Example Usage [usage] -->
7682
7783Refer to the [ API parameters page] ( https://docs.unstructured.io/api-reference/api-services/api-parameters ) for all available parameters.
7884
0 commit comments