UNPKG

553 BPlain TextView Raw
1/** @internal */
2
3/** @internal */
4import { File } from '../types'
5import { AddResult, CID, FileContent } from '../../ipfs/index'
6
7
8export 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
30export default BaseFile