Meteor-Community-Packages / Meteor-CollectionFS

Reactive file manager for Meteor
MIT License
1.05k stars 237 forks source link

How to insert base64 string into newFile.attachData() ? #1011

Open stuurgurs opened 6 years ago

stuurgurs commented 6 years ago

Hello! I store images in my mongo collection in base64 strings and now i want to migrate to FS.collection. I need to make this operation: var newFile = new FS.File(); newFile.attachData(img, {type: 'image/jpeg'}); Images.insert(newFile)

but newFile.attachData() do not underatand base64 when i`m trying to convert it to binary with atob() i get: Uncaught Error: DataMan constructor received unrecognized data string

How i can solve this?

nooitaf commented 6 years ago

You could use a method. Related https://github.com/CollectionFS/Meteor-CollectionFS/issues/803#issuecomment-141089625