@epilot/file-client 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +17 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -18,15 +18,26 @@ npm install --save @epilot/file-client
18
18
  ## Usage
19
19
 
20
20
  ```typescript
21
+ import fs from 'fs';
21
22
  import fileClient from '@epilot/file-client';
22
23
 
23
24
  // get upload params
24
- const uploadParams = await client.uploadFile(null, { filename: 'my-document.pdf', mime_type: 'application/pdf' });
25
-
26
- // upload file as multipart/form-data
27
- const form = new FormData();
28
- formData.append('file', fileToUpload);
29
- const uploadRes = await fileClient.put(uploadParams.data.upload_url, form, { headers: form.getHeaders() });
25
+ const uploadFileRes = await fileClient.uploadFile(null, { filename: 'document.pdf', mime_type: 'application/pdf' });
26
+ const uploadParams = uploadFileRes.data;
27
+
28
+ // upload file to S3
29
+ const file = fs.readFileSync('./document.pdf')
30
+ const uploadRes = await fileClient.put(
31
+ uploadParams.upload_url,
32
+ file,
33
+ { headers: { 'content-type': 'application/json' }}
34
+ );
35
+
36
+ // save file as an entity
37
+ const uploadParams = await fileClient.saveFile(
38
+ null,
39
+ { s3ref: uploadParams.s3ref, access_control: 'private' },
40
+ );
30
41
  ```
31
42
 
32
43
  ## Documentation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epilot/file-client",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Client library for the epilot File API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",