Skip to content

Commit b871e06

Browse files
committed
add: Blob to datafile & resource pool
1 parent a689e35 commit b871e06

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

s/timeline/parts/resource-pool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ export class ResourcePool {
1212
async store(datafile: Datafile) {
1313
const media = await Media.analyze(datafile)
1414
const {hash} = media.datafile.checksum
15-
const {filename, bytes, url} = media.datafile
15+
const {filename, bytes, url, blob} = media.datafile
1616

1717
if (this.#map.has(hash)) {
1818
const alreadyExists = this.#map.require(hash)
1919
alreadyExists.filename = filename
2020
}
2121
else
22-
this.#map.set(hash, {kind: "media", filename, bytes, url})
22+
this.#map.set(hash, {kind: "media", filename, bytes, url, blob})
2323

2424
return media
2525
}

s/timeline/parts/resource.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export namespace Resource {
44
kind: "media"
55
filename: string
66
bytes: Uint8Array
7+
blob: Blob
78
url: string
89
}
910

s/timeline/utils/datafile.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export class Datafile {
55
constructor(
66
public url: string,
77
public bytes: Uint8Array,
8+
public blob: Blob,
89
public filename: string,
910
public checksum: Checksum,
1011
) {}
@@ -15,7 +16,7 @@ export class Datafile {
1516
const checksum = await Checksum.make(bytes)
1617
const filename = name ?? checksum.nickname
1718
const url = URL.createObjectURL(file)
18-
return new this(url, bytes, filename, checksum)
19+
return new this(url, bytes, file, filename, checksum)
1920
}
2021

2122
static async load(path: string) {

0 commit comments

Comments
 (0)