@harperfast/template-vanilla-studio 1.5.13 → 1.5.14
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.
|
@@ -13,11 +13,9 @@ Use this skill when you need to store binary files (images, audio, etc.) in the
|
|
|
13
13
|
|
|
14
14
|
## How It Works
|
|
15
15
|
|
|
16
|
-
1. **Store Binary Data**: In your resource's `post` or `put` method, convert incoming data to Buffers and then to Blobs using `createBlob
|
|
16
|
+
1. **Store Binary Data**: In your resource's `post` or `put` method, convert incoming data to Buffers and then to Blobs using `createBlob` from Harper's globals. Include the MIME type if available:
|
|
17
17
|
|
|
18
18
|
```typescript
|
|
19
|
-
import { createBlob } from 'harperdb';
|
|
20
|
-
|
|
21
19
|
async post(target, record) {
|
|
22
20
|
if (record.data) {
|
|
23
21
|
record.data = createBlob(Buffer.from(record.data, record.encoding || 'base64'), {
|
|
@@ -20,9 +20,9 @@ Use this skill when you need to store unstructured or large binary data (media,
|
|
|
20
20
|
data: Blob
|
|
21
21
|
}
|
|
22
22
|
```
|
|
23
|
-
2. **Create and Store Blobs**: Use `createBlob()` from
|
|
23
|
+
2. **Create and Store Blobs**: Use `createBlob()` from Harper's globals to wrap Buffers or Streams:
|
|
24
24
|
```javascript
|
|
25
|
-
import {
|
|
25
|
+
import { tables } from 'harperdb';
|
|
26
26
|
const blob = createBlob(largeBuffer);
|
|
27
27
|
await tables.MyTable.put('my-id', { data: blob });
|
|
28
28
|
```
|
package/package.json
CHANGED
package/skills-lock.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"harper-best-practices": {
|
|
5
5
|
"source": "harperfast/skills",
|
|
6
6
|
"sourceType": "github",
|
|
7
|
-
"computedHash": "
|
|
7
|
+
"computedHash": "24de04d7a5ebc3a878df177ae971470a229b8ea78b6111da4b46e492d44b5044"
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|