1 |
|
2 |
|
3 |
|
4 | import { File } from '../types'
|
5 | import { AddResult, CID, FileContent } from '../../ipfs/index'
|
6 |
|
7 |
|
8 | export abstract class BaseFile implements File {
|
9 |
|
10 | content: FileContent
|
11 |
|
12 | constructor(content: FileContent) {
|
13 | this.content = content
|
14 | }
|
15 |
|
16 | async put(): Promise<CID> {
|
17 | const { cid } = await this.putDetailed()
|
18 | return cid
|
19 | }
|
20 |
|
21 | async updateContent(content: FileContent): Promise<this> {
|
22 | this.content = content
|
23 | return this
|
24 | }
|
25 |
|
26 | abstract putDetailed(): Promise<AddResult>
|
27 | }
|
28 |
|
29 |
|
30 | export default BaseFile
|