Skip to content

Commit

Permalink
feat(extension): mimetype file in write
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Apr 1, 2023
1 parent 73c6e10 commit e2dd758
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/better-write-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ import {
import { ProjectObject } from 'better-write-types'
import destr from 'destr'

export const writeMimetype = (): TextReader => {
const reader = new TextReader('application/bw+zip')

return reader
}

export const writeBW = async (data: string) => {
const writer = new BlobWriter()
const reader = new TextReader(data)
const json = new TextReader(data)

const zipWriter = new ZipWriter(writer)
await zipWriter.add('data.json', json)

const mimetype = writeMimetype()
await zipWriter.add('mimetype', mimetype)

await zipWriter.add('data.json', reader)
await zipWriter.close()

const target = await writer.getData()
Expand Down

0 comments on commit e2dd758

Please sign in to comment.