use 'name' param as GridFS file's 'filename'

This commit is contained in:
otofune
2017-11-07 09:30:51 +09:00
parent a7762aea4f
commit fb422b4d60
6 changed files with 9 additions and 7 deletions

View File

@ -21,15 +21,17 @@ const migrateToGridFS = async (doc) => {
const id = doc._id
const buffer = doc.data.buffer
const created_at = doc.created_at
const name = doc.name
delete doc._id
delete doc.created_at
delete doc.datasize
delete doc.hash
delete doc.data
delete doc.name
const bucket = await getGridFSBucket()
const added = await writeToGridFS(bucket, buffer, id, `${id}/${doc.name}`, { metadata: doc })
const added = await writeToGridFS(bucket, buffer, id, name, { metadata: doc })
const result = await DriveFile.update(id, {
$set: {