Skip to content

Commit

Permalink
Fix small attachments.
Browse files Browse the repository at this point in the history
  • Loading branch information
millette committed Aug 24, 2016
1 parent 1586f3d commit c49ff4a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const glob = require('glob')
const nano = require('nano')
const pify = require('pify')
const fileType = require('file-type')
const mime = require('mime')

const readFile = (fn, bin) => new Promise((resolve, reject) => fs.readFile(
fn, bin ? null : 'utf-8',
Expand Down Expand Up @@ -141,10 +142,12 @@ module.exports = (ddocPath, dbURL) => {
const ddoc = gg[0]
const atts = gg[1]
const attObj = (fn, f) => {
let ft = fileType(f)
ft = ft && ft.mime ? ft.mime : mime.lookup(fn)
return {
name: path.basename(fn),
data: f,
content_type: fileType(f).mime
content_type: ft
}
}
const ha = atts.map((fn) => readFile(resolver(fn), true).then(attObj.bind(null, fn)))
Expand Down

0 comments on commit c49ff4a

Please sign in to comment.